<!DOCTYPE html>
<html lang="en-US" dir="ltr">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>五大数据类型及API | 金信通智慧办公系统</title>
    <meta name="description" content="档案与电子文档管理系统">
    <meta name="generator" content="VitePress v1.5.0">
    <link rel="preload stylesheet" href="/assets/style.Dp0lbQBF.css" as="style">
    <link rel="preload stylesheet" href="/vp-icons.css" as="style">
    
    <script type="module" src="/assets/app.dV7dGA8w.js"></script>
    <link rel="preload" href="/assets/inter-roman-latin.Di8DUHzh.woff2" as="font" type="font/woff2" crossorigin="">
    <link rel="modulepreload" href="/assets/chunks/theme.CAMB7RoJ.js">
    <link rel="modulepreload" href="/assets/chunks/framework.mqlkf_9D.js">
    <link rel="modulepreload" href="/assets/course_learn_redis_03_data-types.md.C-sFZOhK.lean.js">
    <link rel="icon" href="/icon/favicon.ico">
    <meta name="keywords" content="金信通, 智慧办公, 档案与电子文档管理系统, 文档管理系统, 档案">
    <link rel="dns-prefetch" href="https://fonts.googleapis.com">
    <link rel="dns-prefetch" href="https://fonts.gstatic.com">
    <link rel="preconnect" crossorigin="anonymous" href="https://fonts.googleapis.com">
    <link rel="preconnect" crossorigin="anonymous" href="https://fonts.gstatic.com">
    <meta property="og:url" content="https://www.dotnetshare.com/">
    <meta property="og:locale" content="zh_CN">
    <script>var _hmt=_hmt||[];(function(){var e=document.createElement("script");e.src="https://hm.baidu.com/hm.js?cc5a66c545a0dc6ac6f0b83090e2b806";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)})();</script>
    <script id="check-dark-mode">(()=>{const e=localStorage.getItem("vitepress-theme-appearance")||"auto",a=window.matchMedia("(prefers-color-scheme: dark)").matches;(!e||e==="auto"?a:e==="dark")&&document.documentElement.classList.add("dark")})();</script>
    <script id="check-mac-os">document.documentElement.classList.toggle("mac",/Mac|iPhone|iPod|iPad/i.test(navigator.platform));</script>
  </head>
  <body>
    <div id="app"><div class="Layout" data-v-3efcb1ce><!--[--><!--]--><!--[--><span tabindex="-1" data-v-f2f1af7d></span><a href="#VPContent" class="VPSkipLink visually-hidden" data-v-f2f1af7d> Skip to content </a><!--]--><!----><header class="VPNav" data-v-3efcb1ce data-v-d92d3bf3><div class="VPNavBar" data-v-d92d3bf3 data-v-4d24195f><div class="wrapper" data-v-4d24195f><div class="container" data-v-4d24195f><div class="title" data-v-4d24195f><div class="VPNavBarTitle has-sidebar" data-v-4d24195f data-v-aa77a82d><a class="title" href="/" data-v-aa77a82d><!--[--><!--]--><!----><span data-v-aa77a82d>金信通智慧办公系统</span><!--[--><!--]--></a></div></div><div class="content" data-v-4d24195f><div class="content-body" data-v-4d24195f><!--[--><!--]--><div class="VPNavBarSearch search" data-v-4d24195f><!--[--><!----><div id="local-search"><button type="button" class="DocSearch DocSearch-Button" aria-label="Search"><span class="DocSearch-Button-Container"><span class="vp-icon DocSearch-Search-Icon"></span><span class="DocSearch-Button-Placeholder">Search</span></span><span class="DocSearch-Button-Keys"><kbd class="DocSearch-Button-Key"></kbd><kbd class="DocSearch-Button-Key">K</kbd></span></button></div><!--]--></div><nav aria-labelledby="main-nav-aria-label" class="VPNavBarMenu menu" data-v-4d24195f data-v-03316225><span id="main-nav-aria-label" class="visually-hidden" data-v-03316225> Main Navigation </span><!--[--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/guid/intro.html" tabindex="0" data-v-03316225 data-v-7228a783><!--[--><span data-v-7228a783>管理系统使用</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/command/dotnet.html" tabindex="0" data-v-03316225 data-v-7228a783><!--[--><span data-v-7228a783>档案柜配置</span><!--]--></a><!--]--><!--[--><a class="VPLink link VPNavBarMenuLink" href="/netopensource/" tabindex="0" data-v-03316225 data-v-7228a783><!--[--><span data-v-7228a783>小程序使用</span><!--]--></a><!--]--><!--[--><div class="VPFlyout VPNavBarMenuGroup" data-v-03316225 data-v-ba6b45eb><button type="button" class="button" aria-haspopup="true" aria-expanded="false" data-v-ba6b45eb><span class="text" data-v-ba6b45eb><!----><span data-v-ba6b45eb>链接</span><span class="vpi-chevron-down text-icon" data-v-ba6b45eb></span></span></button><div class="menu" data-v-ba6b45eb><div class="VPMenu" data-v-ba6b45eb data-v-d87007e0><div class="items" data-v-d87007e0><!--[--><!--[--><div class="VPMenuLink" data-v-d87007e0 data-v-7db8e0ca><a class="VPLink link vp-external-link-icon" href="https://malus.dotnetshare.com" target="_blank" rel="noreferrer" data-v-7db8e0ca><!--[--><span data-v-7db8e0ca>MalusAdmin</span><!--]--></a></div><!--]--><!--[--><div class="VPMenuLink" data-v-d87007e0 data-v-7db8e0ca><a class="VPLink link vp-external-link-icon" href="https://gitee.com/Pridejoy/MalusAdmin" target="_blank" rel="noreferrer" data-v-7db8e0ca><!--[--><span data-v-7db8e0ca>Malus(开源地址)</span><!--]--></a></div><!--]--><!--]--></div><!--[--><!--]--></div></div></div><!--]--><!--]--></nav><!----><div class="VPNavBarAppearance appearance" data-v-4d24195f data-v-77825811><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title aria-checked="false" data-v-77825811 data-v-9e221f44 data-v-661c05b3><span class="check" data-v-661c05b3><span class="icon" data-v-661c05b3><!--[--><span class="vpi-sun sun" data-v-9e221f44></span><span class="vpi-moon moon" data-v-9e221f44></span><!--]--></span></span></button></div><div class="VPSocialLinks VPNavBarSocialLinks social-links" data-v-4d24195f data-v-73b344d7 data-v-b07a7149><!--[--><a class="VPSocialLink no-icon" href="/aboutme.html" aria-label="wechat" target="_blank" rel="noopener" data-v-b07a7149 data-v-53b864fb><svg t="1703483542872" class="icon" viewBox="0 0 1309 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6274" width="200" height="200"><path d="M1147.26896 912.681417l34.90165 111.318583-127.165111-66.823891a604.787313 604.787313 0 0 1-139.082747 22.263717c-220.607239 0-394.296969-144.615936-394.296969-322.758409s173.526026-322.889372 394.296969-322.889372C1124.219465 333.661082 1309.630388 478.669907 1309.630388 656.550454c0 100.284947-69.344929 189.143369-162.361428 256.130963zM788.070086 511.869037a49.11114 49.11114 0 0 0-46.360916 44.494692 48.783732 48.783732 0 0 0 46.360916 44.494693 52.090549 52.090549 0 0 0 57.983885-44.494693 52.385216 52.385216 0 0 0-57.983885-44.494692z m254.985036 0a48.881954 48.881954 0 0 0-46.09899 44.494692 48.620028 48.620028 0 0 0 46.09899 44.494693 52.385216 52.385216 0 0 0 57.983886-44.494693 52.58166 52.58166 0 0 0-57.951145-44.494692z m-550.568615 150.018161a318.567592 318.567592 0 0 0 14.307712 93.212943c-14.307712 1.080445-28.746387 1.768001-43.283284 1.768001a827.293516 827.293516 0 0 1-162.394168-22.296458l-162.001279 77.955749 46.328175-133.811485C69.410411 600.858422 0 500.507993 0 378.38496 0 166.683208 208.689602 0 463.510935 0c227.908428 0 427.594322 133.18941 467.701752 312.379588a427.463358 427.463358 0 0 0-44.625655-2.619261c-220.24709 0-394.100524 157.74498-394.100525 352.126871zM312.90344 189.143369a64.270111 64.270111 0 0 0-69.803299 55.659291 64.532037 64.532037 0 0 0 69.803299 55.659292 53.694846 53.694846 0 0 0 57.852923-55.659292 53.465661 53.465661 0 0 0-57.852923-55.659291z m324.428188 0a64.040926 64.040926 0 0 0-69.574114 55.659291 64.302852 64.302852 0 0 0 69.574114 55.659292 53.694846 53.694846 0 0 0 57.951145-55.659292 53.465661 53.465661 0 0 0-57.951145-55.659291z" p-id="6275"></path></svg></a><!--]--></div><div class="VPFlyout VPNavBarExtra extra" data-v-4d24195f data-v-ca0a11f1 data-v-ba6b45eb><button type="button" class="button" aria-haspopup="true" aria-expanded="false" aria-label="extra navigation" data-v-ba6b45eb><span class="vpi-more-horizontal icon" data-v-ba6b45eb></span></button><div class="menu" data-v-ba6b45eb><div class="VPMenu" data-v-ba6b45eb data-v-d87007e0><!----><!--[--><!--[--><!----><div class="group" data-v-ca0a11f1><div class="item appearance" data-v-ca0a11f1><p class="label" data-v-ca0a11f1>主题</p><div class="appearance-action" data-v-ca0a11f1><button class="VPSwitch VPSwitchAppearance" type="button" role="switch" title aria-checked="false" data-v-ca0a11f1 data-v-9e221f44 data-v-661c05b3><span class="check" data-v-661c05b3><span class="icon" data-v-661c05b3><!--[--><span class="vpi-sun sun" data-v-9e221f44></span><span class="vpi-moon moon" data-v-9e221f44></span><!--]--></span></span></button></div></div></div><div class="group" data-v-ca0a11f1><div class="item social-links" data-v-ca0a11f1><div class="VPSocialLinks social-links-list" data-v-ca0a11f1 data-v-b07a7149><!--[--><a class="VPSocialLink no-icon" href="/aboutme.html" aria-label="wechat" target="_blank" rel="noopener" data-v-b07a7149 data-v-53b864fb><svg t="1703483542872" class="icon" viewBox="0 0 1309 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6274" width="200" height="200"><path d="M1147.26896 912.681417l34.90165 111.318583-127.165111-66.823891a604.787313 604.787313 0 0 1-139.082747 22.263717c-220.607239 0-394.296969-144.615936-394.296969-322.758409s173.526026-322.889372 394.296969-322.889372C1124.219465 333.661082 1309.630388 478.669907 1309.630388 656.550454c0 100.284947-69.344929 189.143369-162.361428 256.130963zM788.070086 511.869037a49.11114 49.11114 0 0 0-46.360916 44.494692 48.783732 48.783732 0 0 0 46.360916 44.494693 52.090549 52.090549 0 0 0 57.983885-44.494693 52.385216 52.385216 0 0 0-57.983885-44.494692z m254.985036 0a48.881954 48.881954 0 0 0-46.09899 44.494692 48.620028 48.620028 0 0 0 46.09899 44.494693 52.385216 52.385216 0 0 0 57.983886-44.494693 52.58166 52.58166 0 0 0-57.951145-44.494692z m-550.568615 150.018161a318.567592 318.567592 0 0 0 14.307712 93.212943c-14.307712 1.080445-28.746387 1.768001-43.283284 1.768001a827.293516 827.293516 0 0 1-162.394168-22.296458l-162.001279 77.955749 46.328175-133.811485C69.410411 600.858422 0 500.507993 0 378.38496 0 166.683208 208.689602 0 463.510935 0c227.908428 0 427.594322 133.18941 467.701752 312.379588a427.463358 427.463358 0 0 0-44.625655-2.619261c-220.24709 0-394.100524 157.74498-394.100525 352.126871zM312.90344 189.143369a64.270111 64.270111 0 0 0-69.803299 55.659291 64.532037 64.532037 0 0 0 69.803299 55.659292 53.694846 53.694846 0 0 0 57.852923-55.659292 53.465661 53.465661 0 0 0-57.852923-55.659291z m324.428188 0a64.040926 64.040926 0 0 0-69.574114 55.659291 64.302852 64.302852 0 0 0 69.574114 55.659292 53.694846 53.694846 0 0 0 57.951145-55.659292 53.465661 53.465661 0 0 0-57.951145-55.659291z" p-id="6275"></path></svg></a><!--]--></div></div></div><!--]--><!--]--></div></div></div><!--[--><!--]--><button type="button" class="VPNavBarHamburger hamburger" aria-label="mobile navigation" aria-expanded="false" aria-controls="VPNavScreen" data-v-4d24195f data-v-c5b212bb><span class="container" data-v-c5b212bb><span class="top" data-v-c5b212bb></span><span class="middle" data-v-c5b212bb></span><span class="bottom" data-v-c5b212bb></span></span></button></div></div></div></div><div class="divider" data-v-4d24195f><div class="divider-line" data-v-4d24195f></div></div></div><!----></header><div class="VPLocalNav has-sidebar empty" data-v-3efcb1ce data-v-1c741b14><div class="container" data-v-1c741b14><button class="menu" aria-expanded="false" aria-controls="VPSidebarNav" data-v-1c741b14><span class="vpi-align-left menu-icon" data-v-1c741b14></span><span class="menu-text" data-v-1c741b14>菜单</span></button><div class="VPLocalNavOutlineDropdown" style="--vp-vh:0px;" data-v-1c741b14 data-v-83a9fff7><button data-v-83a9fff7>回到顶部</button><!----></div></div></div><aside class="VPSidebar" data-v-3efcb1ce data-v-c73c6ab0><div class="curtain" data-v-c73c6ab0></div><nav class="nav" id="VPSidebarNav" aria-labelledby="sidebar-aria-label" tabindex="-1" data-v-c73c6ab0><span class="visually-hidden" id="sidebar-aria-label" data-v-c73c6ab0> Sidebar Navigation </span><!--[--><!--]--><!--[--><div class="no-transition group" data-v-7c41cf7c><section class="VPSidebarItem level-0" data-v-7c41cf7c data-v-ecbfd8bc><div class="item" role="button" tabindex="0" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><h2 class="text" data-v-ecbfd8bc>学习路径</h2><!----></div><div class="items" data-v-ecbfd8bc><!--[--><div class="VPSidebarItem level-1 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_path/index.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>学习资料</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_path/webapi.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>AspNetCore开发指南</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_path/csharp.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>Csharp代码大全</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-1 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_path/dotnetskill.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>DotNet知识技能大全</p><!--]--></a><!----></div><!----></div><!--]--></div></section></div><div class="no-transition group" data-v-7c41cf7c><section class="VPSidebarItem level-0 has-active" data-v-7c41cf7c data-v-ecbfd8bc><div class="item" role="button" tabindex="0" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><h2 class="text" data-v-ecbfd8bc>系列</h2><!----></div><div class="items" data-v-ecbfd8bc><!--[--><section class="VPSidebarItem level-1 collapsible collapsed" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" role="button" tabindex="0" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><h3 class="text" data-v-ecbfd8bc>TS快速上手</h3><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-ecbfd8bc><span class="vpi-chevron-right caret-icon" data-v-ecbfd8bc></span></div></div><div class="items" data-v-ecbfd8bc><!--[--><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_ts/1_type.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>1. 基础类型</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_ts/2_interface.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>2. 接口</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_ts/3_class.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>3. 类</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_ts/4_function.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>4. 函数</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_ts/5_generic.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>5. 泛型</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_ts/6_other.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>6. 其它</p><!--]--></a><!----></div><!----></div><!--]--></div></section><section class="VPSidebarItem level-1 collapsible collapsed" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" role="button" tabindex="0" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><h3 class="text" data-v-ecbfd8bc>十大排序</h3><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-ecbfd8bc><span class="vpi-chevron-right caret-icon" data-v-ecbfd8bc></span></div></div><div class="items" data-v-ecbfd8bc><!--[--><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_sort/01_bubblesort.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>1.冒泡排序</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_sort/02_selectionsort.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>2.选择排序</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_sort/03_insertionsort.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>3.插入排序</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_sort/04_shellsort.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>4.希尔排序</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_sort/05_mergesort.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>5.归并排序</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_sort/06_quicksort.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>6.快速排序</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_sort/07_heapsort.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>7.堆排序</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_sort/08_countingsort.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>8.计数排序</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_sort/09_bucketsort.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>9.桶排序</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_sort/10_radixsort.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>10.基数排序</p><!--]--></a><!----></div><!----></div><!--]--></div></section><section class="VPSidebarItem level-1 collapsible collapsed" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" role="button" tabindex="0" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><h3 class="text" data-v-ecbfd8bc>设计模式</h3><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-ecbfd8bc><span class="vpi-chevron-right caret-icon" data-v-ecbfd8bc></span></div></div><div class="items" data-v-ecbfd8bc><!--[--><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_design/00_index.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>00.前言</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_design/01_Singleton.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>01.单例模式</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_design/02_FactoryMethod.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>02.工厂方法模式</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_design/03_AbstractFactory.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>03.抽象工厂模式</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_design/04_Builder.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>04.建造者模式</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_design/05_Prototype.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>05.原型模式</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_design/06_Adapter.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>06.适配器模式</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_design/07_Bridge.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>07.桥接模式</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_design/08_Composite.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>08.组合模式</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_design/09_Decorator.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>09.装饰器模式</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_design/10_Facade.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>10.外观模式</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_design/11_Flyweight.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>11.享元模式</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_design/12_Proxy.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>12.代理模式</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_design/13_ChainOfResponsibility.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>13.责任链模式</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_design/14_Command.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>14.命令模式</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_design/15_Interpreter.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>15.解释器模式</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_design/16_Iterator.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>16.迭代器模式</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_design/17_Mediator.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>17.中介者模式</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_design/18_Memento.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>18.备忘录模式</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_design/19_Observer.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>19.观察者模式</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_design/20_State.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>20.状态模式</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_design/21_Strategy.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>21.策略模式</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_design/22_TemplateMethod.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>22.模板方法模式</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_design/23_Visitor.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>23.访问者模式</p><!--]--></a><!----></div><!----></div><!--]--></div></section><section class="VPSidebarItem level-1 collapsible collapsed" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" role="button" tabindex="0" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><h3 class="text" data-v-ecbfd8bc>ElasticSearch</h3><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-ecbfd8bc><span class="vpi-chevron-right caret-icon" data-v-ecbfd8bc></span></div></div><div class="items" data-v-ecbfd8bc><!--[--><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_es/01_introduce.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>01.基础概念</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_es/02_install.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>02.安装</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_es/03_simple-curd.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>03.基本操作</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_es/04_hight-curd.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>04.高级操作</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_es/05_net-curd.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>05.NET操作</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_es/07_cluster.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>07.搭建集群</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_es/08_high-concept.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>08.进阶概念</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_es/09_distributed.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>09.分布式集群和路由计算</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_es/10_shards-control.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>10.分片控制流程</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_es/11_shards-principle.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>11.分片操作原理</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_es/12_analysis.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>12.多种分析器</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_es/13_handle.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>13.冲突问题处理</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_es/14_optimization.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>14.进阶优化</p><!--]--></a><!----></div><!----></div><!--]--></div></section><section class="VPSidebarItem level-1 collapsible collapsed has-active" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" role="button" tabindex="0" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><h3 class="text" data-v-ecbfd8bc>Redis</h3><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-ecbfd8bc><span class="vpi-chevron-right caret-icon" data-v-ecbfd8bc></span></div></div><div class="items" data-v-ecbfd8bc><!--[--><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_redis/01_introduce.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>01.基础概念</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_redis/02_install.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>02.安装</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_redis/03_data-types.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>03.五大数据类型及API</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_redis/04_new-types.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>04.新增三大数据类型</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_redis/05_configuration.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>05.配置文件</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_redis/06_publish-subscribe.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>06.发布和订阅</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_redis/07_net.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>07.NET整合</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_redis/08_affair.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>08.事务与锁</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_redis/09_persistence.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>09.两种持久化</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_redis/10_master-slave.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>10.主从复制</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_redis/11_cluster.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>11.集群搭建</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_redis/12_application.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>12.应用问题</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_redis/13_distributed-lock.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>13.分布式锁</p><!--]--></a><!----></div><!----></div><!--]--></div></section><section class="VPSidebarItem level-1 collapsible collapsed" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" role="button" tabindex="0" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><h3 class="text" data-v-ecbfd8bc>RabbitMQ</h3><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-ecbfd8bc><span class="vpi-chevron-right caret-icon" data-v-ecbfd8bc></span></div></div><div class="items" data-v-ecbfd8bc><!--[--><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_rabbit/01_middleware.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>01.中间件</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_rabbit/02_mq.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>02.消息队列</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_rabbit/03_introduce.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>03.介绍</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_rabbit/04_install.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>04.安装</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_rabbit/05_basic.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>05.Net基础整合</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_rabbit/06_ackpub.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>06.应答与发布</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_rabbit/07_exchange.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>07.交换机</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_rabbit/08_dead.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>08.死信队列</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_rabbit/09_delay.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>09.延迟队列</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_rabbit/10_hightpub.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>10.高发部确认</p><!--]--></a><!----></div><!----></div><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_rabbit/11_priority.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>11.优先级</p><!--]--></a><!----></div><!----></div><!--]--></div></section><section class="VPSidebarItem level-1 collapsible collapsed" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" role="button" tabindex="0" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><h3 class="text" data-v-ecbfd8bc>Docker</h3><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-ecbfd8bc><span class="vpi-chevron-right caret-icon" data-v-ecbfd8bc></span></div></div><div class="items" data-v-ecbfd8bc><!--[--><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_docker/01_introduce.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>01.基础概念</p><!--]--></a><!----></div><!----></div><!--]--></div></section><section class="VPSidebarItem level-1 collapsible collapsed" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" role="button" tabindex="0" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><h3 class="text" data-v-ecbfd8bc>Kubernetes</h3><div class="caret" role="button" aria-label="toggle section" tabindex="0" data-v-ecbfd8bc><span class="vpi-chevron-right caret-icon" data-v-ecbfd8bc></span></div></div><div class="items" data-v-ecbfd8bc><!--[--><div class="VPSidebarItem level-2 is-link" data-v-ecbfd8bc data-v-ecbfd8bc><div class="item" data-v-ecbfd8bc><div class="indicator" data-v-ecbfd8bc></div><a class="VPLink link link" href="/course/learn_k8s/01_introduce.html" data-v-ecbfd8bc><!--[--><p class="text" data-v-ecbfd8bc>01.基础概念</p><!--]--></a><!----></div><!----></div><!--]--></div></section><!--]--></div></section></div><!--]--><!--[--><!--]--></nav></aside><div class="VPContent has-sidebar" id="VPContent" data-v-3efcb1ce data-v-66a16a78><div class="VPDoc has-sidebar has-aside" data-v-66a16a78 data-v-6dff760d><!--[--><!--]--><div class="container" data-v-6dff760d><div class="aside" data-v-6dff760d><div class="aside-curtain" data-v-6dff760d></div><div class="aside-container" data-v-6dff760d><div class="aside-content" data-v-6dff760d><div class="VPDocAside" data-v-6dff760d data-v-a8d7bfb8><!--[--><!--]--><!--[--><!--]--><nav aria-labelledby="doc-outline-aria-label" class="VPDocAsideOutline" data-v-a8d7bfb8 data-v-2a6fc259><div class="content" data-v-2a6fc259><div class="outline-marker" data-v-2a6fc259></div><div aria-level="2" class="outline-title" id="doc-outline-aria-label" role="heading" data-v-2a6fc259>页面导航</div><ul class="VPDocOutlineItem root" data-v-2a6fc259 data-v-604603b9><!--[--><!--]--></ul></div></nav><!--[--><!--]--><div class="spacer" data-v-a8d7bfb8></div><!--[--><!--]--><!----><!--[--><!--]--><!--[--><!--]--></div></div></div></div><div class="content" data-v-6dff760d><div class="content-container" data-v-6dff760d><!--[--><!--]--><main class="main" data-v-6dff760d><div style="position:relative;" class="vp-doc _course_learn_redis_03_data-types" data-v-6dff760d><div><h1 id="五大数据类型及api" tabindex="-1">五大数据类型及API <a class="header-anchor" href="#五大数据类型及api" aria-label="Permalink to &quot;五大数据类型及API&quot;">​</a></h1><p>Redis 常用的五大数据类型，这也是开发常用的数据类型，下面我们来学习每一个数据类型和其他的 API 命令。</p><h2 id="五大数据类型" tabindex="-1">五大数据类型 <a class="header-anchor" href="#五大数据类型" aria-label="Permalink to &quot;五大数据类型&quot;">​</a></h2><ul><li><p>String （字符串类型）</p><p>String 是 Redis 最基本的类型，你可以理解成 Memcached 一模一样的类型，一个 key 对应一个 value。</p><p>String 类型是二进制安全的，意思是 Redis 的 String 可以包含任何数据，比如 jpg 图片或者序列化的对象。</p><p>String 类型是 redis 最基本的数据类型，一个 Redis 中字符串 value 最多可以是 512M。</p></li><li><p>Hash（哈希，类似 Java 里的 Map）</p><p>Redis hash 是一个键值对集合。</p><p>Redis hash 是一个 String 类型的 field 和 value 的映射表，hash 特别适合用于存储对象。</p><p>类似 Java 里面的 Map</p></li><li><p>List（列表）</p><p>Redis 列表是简单的字符串列表，按照插入顺序排序，你可以添加一个元素到列表的头部（左边）或者尾部（右边）。它的底层实际是个链表。</p></li><li><p>Set（集合）</p><p>Redis 的 Set 是 String 类型的无序集合，它是通过 HashTable 实现的。</p></li><li><p>Zset（sorted set：有序集合）</p><p>Redis zset 和 set 一样，也是 String 类型元素的集合，且不允许重复的成员。</p><p>不同的是每个元素都会关联一个 double 类型的分数。</p><p>Redis 正是通过分数来为集合中的成员进行从小到大的排序，zset 的成员是唯一的，但是分数（Score）却可以重复。</p></li></ul><p><strong>命令大小写都可以，如果你只想单纯看 API，不想看例子，请移到最下面的 <a href="#指令总结">指令总结</a>。</strong></p><h2 id="键-key-命令" tabindex="-1">键(key)命令 <a class="header-anchor" href="#键-key-命令" aria-label="Permalink to &quot;键(key)命令&quot;">​</a></h2><p>查看当前数据库的 key 的数量</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">dbsize</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><code>keys *</code> 指令查看当前库所有 key</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">keys</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> *</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">empty</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> list</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> or</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> set</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">set</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> name</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> kele</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">OK</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">keys</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> *</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;name&quot;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><p><code>exists key</code> 指令判断某个 key 是否存在</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">EXISTS</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> name</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">EXISTS</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> name1</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">0</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><p><code>type key</code> 指令查看 key 的类型是哪个</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">set</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> name</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> kele</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">OK</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">get</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> name</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">&quot;kele&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">type</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> name</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">string</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><p><code>del key</code> 指令删除指定的 key</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379[1]</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">del</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> name</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379[1]</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">keys</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> *</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">empty</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> array</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><p><code>unlink key</code> 指令根据 value 选择非阻塞删除（先将 keys 从 keysapce 元数据中删除，真正的删除会在后续异步操作）</p><div class="language- vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang"></span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span>127.0.0.1:6379[1]&gt; unlink key name</span></span>
<span class="line"><span>(integer) 1</span></span>
<span class="line"><span>127.0.0.1:6379[1]&gt; keys *</span></span>
<span class="line"><span>(empty array)</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><p><code>expire key time</code> 指令给指定的 key 设置过期时间（time 以秒为单位），当 key 过期时(生存时间为 0 )，它会被自动删除</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">set</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> name</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> kele</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">OK</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">expire</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> name</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 10</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><p><code>ttl key</code> 指令查看 key 还有多少秒过期，-1 表示永不过期，-2 表示已过期</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">set</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> name</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> kele</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">OK</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">expire</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> name</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 10</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ttl</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> name</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">4</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ttl</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> name</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ttl</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> name</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">-2</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">keys</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> *</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">empty</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> list</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> or</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> set</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br></div></div><p><code>select num</code> 指令选择数据库，num 代表从 0-16，默认是 0</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">select</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> 7</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><code>flushdb</code> 指令清空当前库</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">flushdb</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p><code>flushall</code> 指令清空所有库</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">flushall</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><h2 id="字符串string" tabindex="-1">字符串String <a class="header-anchor" href="#字符串string" aria-label="Permalink to &quot;字符串String&quot;">​</a></h2><h3 id="单键单值" tabindex="-1">单键单值 <a class="header-anchor" href="#单键单值" aria-label="Permalink to &quot;单键单值&quot;">​</a></h3><ul><li><p><code>set &lt;key&gt; &lt;value&gt;</code> 指令添加键值对：</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">set</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">valu</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">e</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>注意，当 key 不存在，则将 key-value 存入数据库，如果存在，则覆盖原来 value</p><p>示例：Redis 的分布式锁应用</p><div class="language-SH vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">SH</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">set</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> lock</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> locked</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> nx</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> ex</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 10</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>key 为 lock 的值 locked 在 10 秒内无法重新赋值，只有 10 秒后过期了，才能给 lock 赋值</p></li><li><p><code>get &lt;key&gt;</code> 查看对应键值：</p><div class="language-SH vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">SH</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">get</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></li><li><p><code>append &lt;key&gt; &lt;value&gt;</code> 追加到原值的末尾：</p><div class="language-SH vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">SH</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">append</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">valu</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">e</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></li><li><p><code>strlen &lt;key&gt;</code> 获得值的长度：</p><div class="language-SH vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">SH</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">strlen</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></li><li><p><code>setnx &lt;key&gt; &lt;value&gt;</code> 指令只有 key 不存在时，才加入该 key 的值：</p><div class="language-SH vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">SH</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">setnx</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">valu</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">e</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></li></ul><p>案例：</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">set</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> key1</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> value1</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 设置值</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">OK</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">get</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> key1</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 获得key</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">&quot;value1&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">del</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> key1</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 删除key</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">keys</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> *</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 查看全部的key</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">empty</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> list</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> or</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> set</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">exists</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> key1</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 确保 key1 不存在</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">0</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">append</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> key1</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;hello&quot;</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 对不存在的 key 进行 APPEND，等同于 SET key1 &quot;hello&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">5</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 字符长度</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">APPEND</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> key1</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;-2333&quot;</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 对已存在的字符串进行 APPEND</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">10</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 长度从 5 个字符增加到 10 个字符</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">get</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> key1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">&quot;hello-2333&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">strlen</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> key1</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # # 获取字符串的长度</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">10</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br></div></div><h3 id="自增自减" tabindex="-1">自增自减 <a class="header-anchor" href="#自增自减" aria-label="Permalink to &quot;自增自减&quot;">​</a></h3><ul><li><p><code>incr &lt;key&gt;</code> 指令将 key 中储存的数字值增 1，只能对数字值操作，如果为空，新增值为 1：</p><div class="language-SH vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">SH</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">incr</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></li><li><p><code>decr &lt;key&gt;</code> 指令将 key 中储存的数字值减 1，只能对数字值操作，如果为空，新增值为 -1：</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">decr</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></li><li><p><code>incrby / decrby &lt;步长&gt;</code> 指令将 key 中储存的数字值增减。自定义步长：</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">incrby</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> /</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> decrby</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">步</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">长</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></li></ul><p>案例：</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">set</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> views</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 0</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 设置浏览量为 0</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">OK</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">incr</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> views</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 浏览 + 1</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">incr</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> views</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 浏览 + 1</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">2</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">decr</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> views</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 浏览 - 1</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">incrby</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> views</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 10</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # +10</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">11</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">decrby</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> views</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 10</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # -10</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br></div></div><h3 id="多键多值" tabindex="-1">多键多值 <a class="header-anchor" href="#多键多值" aria-label="Permalink to &quot;多键多值&quot;">​</a></h3><ul><li><p><code>mset &lt;key1&gt; &lt;value&gt; &lt;key2&gt; &lt;value2&gt; ......</code> 指令设置一个或者多个 key-value 键值对</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">mset</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">key</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">1&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">valu</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">e</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">key</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">2&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">value</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">2&gt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> ......</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></li><li><p><code>mget &lt;key1&gt; &lt;key2&gt; ......</code> 指令获取一个或者多个 key-value 键值对</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">mget</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">key</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">1&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">key</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">2&gt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> ......</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></li><li><p><code>msetnx &lt;key1&gt; &lt;value&gt; &lt;key2&gt; &lt;value2&gt; ......</code> 指令同时设置一个或多个 key-value 对，当且仅当所有给定 key 都不存在</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">msetnx</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">key</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">1&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">valu</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">e</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">key</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">2&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">value</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">2&gt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> ......</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></li></ul><p>案例：</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">mset</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> k10</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> v10</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> k11</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> v11</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> k12</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> v12</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">OK</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">keys</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> *</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;k12&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;k11&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">3</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;k10&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">mget</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> k10</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> k11</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> k12</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> k13</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;v10&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;v11&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">3</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;v12&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">4</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) (</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">nil</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">msetnx</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> k10</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> v10</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> k15</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> v15</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 原子性操作</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">0</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">get</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> key15</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">nil</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br></div></div><h3 id="range范围" tabindex="-1">range范围 <a class="header-anchor" href="#range范围" aria-label="Permalink to &quot;range范围&quot;">​</a></h3><ul><li><p><code>getrange &lt;key&gt; &lt;起始位置&gt; &lt;结束位置&gt;</code> 指令获得值的范围，类似 Java 中的 substring</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">getrange</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">起始位</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">置</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">结束位</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">置</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></li><li><p><code>setrange &lt;key&gt; &lt;起始位置&gt; &lt;value&gt;</code> 指令用 value 覆写所储存的字符串值，从 &lt;起始位置&gt; 开始(索引从 0 开始)</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">setrange</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">起始位</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">置</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">valu</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">e</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></li></ul><p>案例：</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">set</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> key2</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> abcd123456</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 设置 key2 的值</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">OK</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">getrange</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> key2</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 0</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -1</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 获得全部的值</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">&quot;abcd123456&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">getrange</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> key2</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 0</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 2</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 截取部分字符串</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">&quot;abc&quot;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><ul><li><p><code>setrange &lt;key&gt; &lt;位置&gt; &lt;newValue&gt;</code> 指令设置指定区间范围内的值</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">setrange</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">位</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">置</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">newValu</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">e</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></li></ul><p>案例：</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">get</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> key2</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">&quot;abcd123456&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">setrange</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> key2</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 1</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> xx</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 替换值</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">10</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">get</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> key2</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">&quot;axxd123456&quot;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><p>从位置 1 开始，将值替换为 xx，因为 xx 长度为 2，所以替换到位置 3 就结束了。</p><h3 id="键值条件" tabindex="-1">键值条件 <a class="header-anchor" href="#键值条件" aria-label="Permalink to &quot;键值条件&quot;">​</a></h3><ul><li><p><code>setex &lt;key&gt; &lt;过期时间/秒&gt; &lt;value&gt;</code> 指令设置键值的同时，设置过期时间，单位秒</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">setex</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">过期时间/</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">秒</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">valu</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">e</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></li><li><p><code>psetex &lt;key&gt; &lt;过期时间/毫秒&gt; &lt;value&gt;</code> 指令设置键值的同时，设置过期时间，单位毫秒</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">psetex</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">过期时间/毫</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">秒</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">valu</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">e</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></li></ul><p>案例：</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">setex</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> key3</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 60</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> expire</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 设置过期时间</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">OK</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ttl</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> key3</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 查看剩余的时间</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">55</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">setnx</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> mykey</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;redis&quot;</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 如果不存在就设置，成功返回1</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">setnx</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> mykey</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;mongodb&quot;</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 如果值存在则不覆盖值，返回0</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">0</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">get</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> mykey</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">&quot;redis&quot;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br></div></div><ul><li><p><code>getset &lt;key&gt; &lt;value&gt;</code> 指令以新换旧，设置了新值同时获得旧值</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">getset</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">valu</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">e</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></li></ul><p>案例：</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">getset</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> db</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> mongodb</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 没有旧值，返回 nil</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">nil</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">get</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> db</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">&quot;mongodb&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">getset</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> db</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> redis</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 返回旧值 mongodb</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">&quot;mongodb&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">get</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> db</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">&quot;redis&quot;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div><h3 id="存储对象" tabindex="-1">存储对象 <a class="header-anchor" href="#存储对象" aria-label="Permalink to &quot;存储对象&quot;">​</a></h3><p>格式：</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">set</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> user:1</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> value（json数据）</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>案例：</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">mset</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> user:1:name</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> zhangsan</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> user:1:age</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 2</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">OK</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">mget</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> user:1:name</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> user:1:age</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;zhangsan&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;2&quot;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><p>案例：</p><blockquote><p>java 中的 i++ 是否是原子操作？</p></blockquote><p>不是。</p><blockquote><p>当 i = 0 时，如果有两个线程分别对 i 进行 ++100 次，值是多少？</p></blockquote><p>2-200。</p><h2 id="列表list" tabindex="-1">列表List <a class="header-anchor" href="#列表list" aria-label="Permalink to &quot;列表List&quot;">​</a></h2><p>List 的特点：单键多值。底层实际是个双向链表，对两端的操作性能很高，通过索引下标的操作中间的节点性能会较差。</p><ul><li><p><code>lpush/rpush &lt;key&gt; &lt;value1&gt; &lt;value2&gt; &lt;value3&gt; ...</code> 指令从左边 / 右边插入一个或多个值，左右也就是首尾</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">lpush/rpush</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">value</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">1&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">value</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">2&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">value</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">3&gt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> ...</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>例子：</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">lpush</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> k1</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> v1</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> v2</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> v3</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></li><li><p><code>lrange &lt;key&gt; &lt;start&gt; &lt;stop&gt;</code> 指令按照索引下标获得元素(从左到右，先进后出)</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">lrange</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">star</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">t</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">sto</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">p</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></li><li><p><code>lrange &lt;key&gt; 0 -1</code> 指令如果 start 是 0，stop 是 -1，代表获取所有元素</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">lrange</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 0</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -1</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></li></ul><p>案例：</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">lpush</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> list</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;one&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">lpush</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> list</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;two&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">2</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">rpush</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> list</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;right&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">3</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">lrange</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> list</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 0</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;two&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;one&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">3</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;right&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">lrange</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> list</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 0</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;two&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;one&quot;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br></div></div><ul><li><p><code>lindex &lt;key&gt; &lt;index&gt;</code> 指令按照索引下标获得元素(从左到右)（-1 代表最后一个，0 代表是第一个）</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">lindex</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">inde</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">x</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>例子：</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">lindex</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> list</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 1</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">nil</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">lindex</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> list</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 0</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">&quot;one&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">lindex</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> list</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">&quot;one&quot;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div></li><li><p><code>lpop/rpop &lt;key&gt;</code> 指令从左边 / 右边吐出一个值。吐出后该值就不存在 key 中</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">lpop/rpop</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>例子：</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">lpop</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> list</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">&quot;two&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">rpop</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> list</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">&quot;right&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">lrange</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> list</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 0</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;one&quot;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div></li><li><p><code>rpoplpush &lt;key1&gt; &lt;key2&gt;</code> 指令列表右边吐出一个值，插到列表左边，其中 key1 是 rpop 的 key，key2 是 lpush 的 key</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">rpoplpush</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">key</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">1&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">key</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">2&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>例子：</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">rpush</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> mylist</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;hello&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">rpush</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> mylist</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;foo&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">2</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">rpush</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> mylist</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;bar&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">3</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">rpoplpush</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> mylist</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> myotherlist</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">&quot;bar&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">lrange</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> mylist</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 0</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;hello&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;foo&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">lrange</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> myotherlist</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 0</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;bar&quot;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br></div></div></li><li><p><code>llen &lt;key&gt;</code> 指令获得列表长度</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">llen</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>例子：</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">flushdb</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">OK</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">lpush</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> list</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;one&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">lpush</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> list</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;two&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">2</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">lpush</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> list</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;three&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">3</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">llen</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> list</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 返回列表的长度</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">3</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div></li><li><p><code>linsert &lt;key&gt; before/after &lt;value&gt; &lt;newValue&gt;</code> 指令在元素某个值的前面 / 后面插入新值，如果 value 有多个，则插入最前面的那个</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">linsert</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> before/after</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">valu</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">e</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">newValu</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">e</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>例子：</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">rpush</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> mylist</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;Hello&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">rpush</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> mylist</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;world&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">2</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">lrange</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> mylist</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 0</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;Hello&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;world&quot;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">linsert</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> mylist</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> BEFORE</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;world&quot;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;There&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">3</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">lrange</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> mylist</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 0</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;Hello&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;There&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">3</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;world&quot;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br></div></div></li><li><p><code>lrem &lt;key&gt; &lt;n&gt; &lt;value&gt;</code> 指令从左边删除 n 个 value（从左到右），如果有多个一样的 lement，则删除列表最前面的</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">lrem</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">n</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">valu</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">e</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>例子：</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">lrem</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> list</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 1</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;two&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">lrange</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> list</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 0</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;three&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;one&quot;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div></li><li><p><code>lset &lt;key&gt; &lt;index&gt; &lt;value&gt;</code> 指令将列表 key 下标为 index 的值替换成 value</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">lset</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">inde</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">x</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">valu</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">e</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>例子：</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">exists</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> list</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 对空列表(key 不存在)进行 LSET</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">0</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">lset</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> list</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 0</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> item</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 报错</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">error</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">ERR</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> no</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> such</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> key</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">lpush</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> list</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;value1&quot;</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 对非空列表进行 LSET</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">lrange</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> list</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 0</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 0</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;value1&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">lset</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> list</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 0</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;new&quot;</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 更新值</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">OK</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">lrange</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> list</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 0</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 0</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;new&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">lset</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> list</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 1</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;new&quot;</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # index 超出范围报错</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">error</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">ERR</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> index</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> out</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> of</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> range</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br></div></div></li><li><p><code>ltrim key</code> 指令对一个列表进行修剪(trim)，只保留指定列表中区间内的元素，不在指定区间之内的元素都将被删除</p><div class="language-bash vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">rpush</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> mylist</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;hello&quot;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;hello&quot;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;hello2&quot;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;hello3&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">4</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ltrim</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> mylist</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 1</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 2</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">OK</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">lrange</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> mylist</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 0</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;hello&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;hello2&quot;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div></li></ul><p>List 的数据结构为快速链表 quickList</p><p>首先在列表元素较少的情况下会使用一块连续的内存存储，这个结构是 ziplist，也即是压缩列表。它将所有的元素紧挨着一起存储，分配的是一块连续的内存。当数据量比较多的时候才会改成 quicklist。因为普通的链表需要的附加指针空间太大，会比较浪费空间。比如这个列表里存的只是 int 类型的数据，结构上还需要两个额外的指针 prev 和 next。</p><p>Redis 将链表和 ziplist 结合起来组成了 quicklist。也就是将多个 ziplist 使用双向指针串起来使用。这样既满足了快速的插入删除性能，又不会出现太大的空间冗余。</p><h2 id="集合set" tabindex="-1">集合Set <a class="header-anchor" href="#集合set" aria-label="Permalink to &quot;集合Set&quot;">​</a></h2><p>集合 Set 特点：无序，不重复。底层其实是一个 value 为 null 的 hash 表，所以添加，删除，查找的复杂度都是 O(1)</p><ul><li><p><code>sadd &lt;key&gt; &lt;value1&gt; &lt;value2&gt; ...</code> 指令将一个或多个 member 元素加入到集合 key 中，已经存在的 member 元素将被忽略</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sadd</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">value</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">1&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">value</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">2&gt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> ...</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>例子：</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sadd</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> k1</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> v1</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> v2</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> v3</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></li><li><p><code>smembers &lt;key&gt;</code> 指令取出该集合的所有值</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">smembers</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></li><li><p><code>sismember &lt;key&gt; &lt;value&gt;</code> 指令判断集合是否为含有该值，有 1，没有 0</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sismember</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">valu</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">e</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></li></ul><p>案例：</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">sadd</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> myset</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;hello&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">sadd</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> myset</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;kele&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">sadd</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> myset</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;kele&quot;</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 重复值不插入 返回 0</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">0</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">smembers</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> myset</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 查看集合中所有成员</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;kele&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;hello&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">sismember</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> myset</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;hello&quot;</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 是否是此集合的成员 是 1</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">sismember</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> myset</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;world&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">0</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br></div></div><ul><li><p><code>scard &lt;key&gt;</code> 指令返回该集合的元素个数</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">scard</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>例子：</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">scard</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> myset</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">2</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div></li><li><p><code>srem &lt;key&gt; &lt;value1&gt; &lt;value2&gt; ...</code> 指令删除集合中的某个元素</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">srem</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">value</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">1&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">value</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">2&gt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> ...</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>例子:</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">srem</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> myset</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;kele&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">smembers</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> myset</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;hello&quot;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div></li><li><p><code>spop &lt;key&gt;</code> 指令随机从该集合中吐出一个值，key 里就没有该值了</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">spop</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>例子：</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">smembers</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> myset</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;kele&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;world&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">3</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;hello&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">spop</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> myset</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">&quot;world&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">spop</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> myset</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 2</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;kele&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;hello&quot;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div></li><li><p><code>srandmember &lt;key&gt; &lt;n&gt;</code> 指令随机从该集合中取出 n 个值。不会从集合中删除</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">srandmember</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">n</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>例子：</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">smembers</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> myset</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;kele&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;world&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">3</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;hello&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">srandmember</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> myset</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">&quot;hello&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">srandmember</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> myset</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 2</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;world&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;kele&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">srandmember</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> myset</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 2</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;kele&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;hello&quot;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br></div></div></li><li><p><code>smove &lt;key1&gt; &lt;key2&gt; &lt;value&gt;</code> 指令把集合中一个值从一个集合移动到另一个集合，其中 key1 为要获取的集合，key2 为放入的集合</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">smove</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">key</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">1&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">key</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">2&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">valu</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">e</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>例子：</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">sadd</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> myset</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;hello&quot;</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # myset 添加元素</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">sadd</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> myset</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;world&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">sadd</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> myset</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;kele&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">sadd</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> myset2</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;set2&quot;</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # myset2 添加元素</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">smove</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> myset</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> myset2</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;kele&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">smembers</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> myset</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;world&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;hello&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">smembers</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> myset2</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;kele&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;set2&quot;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br></div></div></li><li><p><code>sinter &lt;key1&gt; &lt;key2&gt;</code> 指令返回两个集合的交集元素</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sinter</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">key</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">1&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">key</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">2&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></li><li><p><code>sunion &lt;key1&gt; &lt;key2&gt;</code> 指令返回两个集合的并集元素</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sunion</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">key</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">1&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">key</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">2&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></li><li><p><code>sdiff &lt;key1&gt; &lt;key2&gt;</code> 指令返回两个集合的差集元素(key1 中的，不包含 key2 中的)</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">sdiff</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">key</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">1&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">key</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">2&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></li></ul><p>案例：</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">sadd</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> key1</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;a&quot;</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # key1</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">sadd</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> key1</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;b&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">sadd</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> key1</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;c&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">sadd</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> key2</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;c&quot;</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # key2</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">sadd</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> key2</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;d&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">sadd</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> key2</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;e&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">sdiff</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> key1</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> key2</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 差集</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;a&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;b&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">sinter</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> key1</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> key2</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 交集</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;c&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">sunion</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> key1</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> key2</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 并集</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;a&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;b&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">3</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;c&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">4</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;e&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">5</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;d&quot;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br></div></div><p>在微博中，可以将一个用户所有的关注人存在一个集合中，将其所有粉丝存在一个集合。Redis 还为集合提供了求交集、并集、差集等操作，可以非常方便的实现如共同关注、共同喜好、二度好友等功能，对上面的所有集合操作，你还可以使用不同的命令选择将结果返回给客户端还是存集到一个新的集合中。</p><h2 id="哈希hash" tabindex="-1">哈希Hash <a class="header-anchor" href="#哈希hash" aria-label="Permalink to &quot;哈希Hash&quot;">​</a></h2><p>特点：键值对集合，也是一个 string 类型的 field 和 value 的映射表，hash 特别适合用于存储对象。</p><p>类似与 Java 的 <code>Map&lt;String, Map&lt;Object,Object&gt;&gt;</code>，即双 Map。</p><p>通过 key(用户 ID) + field(属性标签) 就可以操作对应属性数据了，既不需要重复存储数据，也不会带来序列化和并发修改控制的问题</p><ul><li><p><code>hset &lt;key&gt; &lt;field1&gt; &lt;value&gt; &lt;field2&gt; &lt;value&gt; ...</code> 指令给集合 key 的 filed 键赋值 value，批量也可以，4.0 之前是 hmset，现在 hset 也可以批量添加</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">hset</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">field</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">1&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">valu</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">e</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">field</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">2&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">valu</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">e</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> ...</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>例子：</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">hset</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> user:1000</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> name</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> kele</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> age</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 18</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> gender</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> boy</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></li><li><p><code>hget &lt;key&gt; &lt;field&gt;</code> 指令从 key 集合取出 value</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">hget</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">fiel</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">d</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>例子：</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">hget</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> user:1000</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> name</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></li><li><p><code>hexists &lt;key&gt; &lt;field&gt;</code> 指令查看哈希表 key 中，给定域 field 是否存在</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">hexists</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">fiel</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">d</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>例子：</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">hexists</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> myhash</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> field1</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">hexists</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> myhash</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> field3</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">0</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div></li><li><p><code>hkeys &lt;key&gt;</code> 指令列出该 hash 集合的所有 field</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">hkeys</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></li><li><p><code>hvals &lt;key&gt;</code> 指令列出该 hash 集合的所有 value</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">hvals</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>例子：</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">hkeys</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> myhash</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;field2&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;field1&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">hvals</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> myhash</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;World&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;Hello&quot;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div></li><li><p><code>hincrby &lt;key&gt; &lt;field&gt; &lt;increment&gt;</code> 指令为哈希表 key 中的域 field 的值加上增量</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">hincrby</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">fiel</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">d</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">incremen</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">t</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>例子：</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">hset</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> myhash</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> field</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 5</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">hincrby</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> myhash</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> field</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 1</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">6</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">hincrby</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> myhash</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> field</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -1</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">5</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">hincrby</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> myhash</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> field</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -10</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">-5</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div></li><li><p><code>hsetnx &lt;key&gt; &lt;filed&gt; &lt;value&gt;</code> 指令将哈希表 key 中的域 field 的值设置为 value ，当且仅当域 field 不存在</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">hsetnx</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">file</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">d</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">valu</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">e</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>例子：</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">hsetnx</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> myhash</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> field1</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;hello&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">  # 设置成功，返回 1 。</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">hsetnx</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> myhash</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> field1</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;world&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">0</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">  # 如果给定字段已经存在，返回 0</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">hget</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> myhash</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> field1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">&quot;hello&quot;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div></li></ul><h2 id="有序集合zset" tabindex="-1">有序集合Zset <a class="header-anchor" href="#有序集合zset" aria-label="Permalink to &quot;有序集合Zset&quot;">​</a></h2><p>有序集合 zset 与普通集合 set 非常相似，是一个没有重复元素的字符串集合。</p><p>不同之处是有序集合的每个成员都关联了一个评分（score），这个评分（score）被用来按照从最低分到最高分的方式排序集合中的成员。集合的成员是唯一的，但是评分可以是重复。</p><ul><li><p><code>zadd &lt;key&gt; &lt;score1&gt; &lt;value1&gt; &lt;score2&gt; &lt;value2&gt; ...</code> 指令将一个或多个 member 元素及其 score 值加入到有序集 key 当中</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">zadd</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">score</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">1&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">value</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">1&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">score</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">2&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">value</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">2&gt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> ...</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>例如：</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">zadd</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> topn</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 1000</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> java</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 800</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> c++</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 600</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> php</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 400</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> js</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></li><li><p><code>zrange &lt;key&gt; &lt;start&gt; &lt;stop&gt; [withscores]</code> 指令返回有序集 key 中，下标在 start 和 stop 之间的元素</p><p>带 WITHSCORES，可以让分数一起和值返回到结果集</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">zrange</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">star</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">t</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">sto</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">p</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> [withscores]</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>例如：(0 和 -1 代表查询所有)</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">zrange</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> topn</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 0</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -1</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> withscores</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;java&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> 1000</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;c++&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> 800</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">3</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;php&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> 600</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">4</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;js&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> 400</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><ul><li><p><code>zrevrange &lt;key&gt; &lt;start&gt; &lt;stop&gt; [withscores]</code> 指令同上，改为从大到小排列</p><pre><code>```sh
zrevrange &lt;key&gt; &lt;start&gt; &lt;stop&gt; [withscores]
```
</code></pre></li></ul></li><li><p><code>zrangebyscore &lt;key&gt; &lt;min&gt; &lt;max&gt; [withscores] [limit offset count]</code> 指令返回有序集 key 中，所有 score 值介于 min 和 max 之间（包括等于 min 或 max）的成员。 有序集成员按 score 值递增（从小到大）次序排列</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">zrangebyscore</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">mi</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">n</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ma</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">x</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> [withscores] [limit offset count]</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><ul><li><p><code>zrevrangebyscore &lt;key&gt; &lt;min&gt; &lt;max&gt; [withscores] [limit offset count]</code> 指令同上，改为从大到小排列</p><pre><code>```sh
zrevrangebyscore &lt;key&gt; &lt;min&gt; &lt;max&gt; [withscores] [limit offset count]
```
</code></pre><p>例子：</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">zadd</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> salary</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 2500</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> xiaoming</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">zadd</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> salary</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 5000</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> xiaohong</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">zadd</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> salary</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 500</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> kele</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># Inf 无穷大量 +∞,同样地,-∞ 可以表示为 -Inf。</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">zrangebyscore</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> salary</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -inf</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> +inf</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 显示整个有序集</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;kele&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;xiaoming&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">3</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;xiaohong&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">zrangebyscore</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> salary</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -inf</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> +inf</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> withscores</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 递增排列</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;kele&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;500&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">3</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;xiaoming&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">4</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;2500&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">5</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;xiaohong&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">6</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;5000&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">zrevrange</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> salary</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 0</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -1</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> withscores</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 递减排列</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;xiaohong&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;5000&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">3</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;xiaoming&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">4</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;2500&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">5</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;kele&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">6</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;500&quot;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"># 显示工资 &lt;= 2500 的所有成员</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">zrangebyscore</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> salary</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -inf</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 2500</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> withscores</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> </span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;kele&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;500&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">3</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;xiaoming&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">4</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;2500&quot;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br></div></div></li></ul></li><li><p><code>zincrby &lt;key&gt; &lt;increment&gt; &lt;value&gt;</code> 指令为元素的 score 加上增量</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">zincrby</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">incremen</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">t</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">valu</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">e</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div></li><li><p><code>zrem &lt;key&gt; &lt;value&gt;</code> 指令删除该集合下，指定值的元素</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">zrem</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">valu</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">e</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>例子：</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">zrange</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> salary</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 0</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;kele&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;xiaoming&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">3</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;xiaohong&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">zrem</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> salary</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> kele</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">zrange</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> salary</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 0</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;xiaoming&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;xiaohong&quot;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div></li><li><p><code>zcount &lt;key&gt; &lt;min&gt; &lt;max&gt;</code> 指令统计该集合，分数区间内的元素个数</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">zcount</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">mi</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">n</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ma</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">x</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>例子：</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">zadd</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> myset</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 1</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;hello&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">zadd</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> myset</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 2</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;world&quot;</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 3</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;kele&quot;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">2</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">zcount</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> myset</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 1</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 3</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">3</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">zcount</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> myset</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 1</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 2</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">2</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div></li><li><p><code>zrank &lt;key&gt; &lt;value&gt;</code> 指令返回该值在集合中的排名，从 0 开始</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">zrank</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">valu</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">e</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>例子：</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">zadd</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> salary</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 2500</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> xiaoming</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">zadd</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> salary</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 5000</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> xiaohong</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">zadd</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> salary</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 500</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> kele</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">zrange</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> salary</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 0</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> -1</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> withscores</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 显示所有成员及其 score 值</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;kele&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;500&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">3</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;xiaoming&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">4</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;2500&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">5</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;xiaohong&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">6</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;5000&quot;</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">zrank</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> salary</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> kele</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 显示 kele 的薪水排名，最少</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">0</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">zrank</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> salary</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> kele</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 显示 xiaohong 的薪水排名，第三</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">2</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br></div></div></li><li><p><code>zrevrank &lt;key&gt; &lt;value&gt;</code> 指令返回有序集中成员的排名。其中有序集成员按分数值递减(从大到小)排序</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">zrevrank</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">ke</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">y</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> &lt;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">valu</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">e</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">&gt;</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br></div></div><p>例子：</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">zrevrank</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> salary</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> kele</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">2</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">127.0.0.1:6379</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&gt; </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">zrevrank</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> salary</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> kele</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">integer</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">) </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">0</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div></li></ul><p>案例：利用 zset 实现一个文章访问量的排行榜</p><div class="language-sh vp-adaptive-theme line-numbers-mode"><button title="Copy Code" class="copy"></button><span class="lang">sh</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">zadd</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> topn</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 1000</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> java</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 800</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> c++</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 600</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> php</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 400</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> js</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;">  # 添加文章以及评分</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">zrevrange</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> topn</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 0</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> 9</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> withscores</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # 评分从大到小查询</span></span></code></pre><div class="line-numbers-wrapper" aria-hidden="true"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>SortedSet(zset)是 Redis 提供的一个非常特别的数据结构，一方面它等价于 Java 的数据结构 Map，可以给每一个元素 value 赋予一个权重 score，另 一方面它又类似于 TreeSet，内部的元素会按照权重 score 进行排序，可以得到每个元素的名次，还可以通过 score 的范围来获取元素的列表。</p><p>zset 底层使用了两个数据结构：</p><ul><li><p>hash，hash 的作用就是关联元素 value 和权重 score，保障元素 value 的唯一性，可以通过元素 value 找到相应的 score 值。</p></li><li><p>跳跃表，跳跃表的目的在于给元素 value 排序，根据 score 的范围获取元素列表。</p></li></ul><h2 id="指令总结" tabindex="-1">指令总结 <a class="header-anchor" href="#指令总结" aria-label="Permalink to &quot;指令总结&quot;">​</a></h2><p>虽然看了五个数据类型的 API 和例子，但是两者混为一起，难免心生抵触，不想看例子，这里以表格形式总结 API，不参杂任何例子。</p><h3 id="键-key-命令-1" tabindex="-1">键(key)命令 <a class="header-anchor" href="#键-key-命令-1" aria-label="Permalink to &quot;键(key)命令&quot;">​</a></h3><table tabindex="0"><thead><tr><th>指令</th><th>含义</th></tr></thead><tbody><tr><td>dbsize</td><td>查看当前数据库的 key 的数量</td></tr><tr><td>keys *</td><td>指令查看当前库所有 key</td></tr><tr><td>exists key</td><td>指令判断某个 key 是否存在</td></tr><tr><td>type key</td><td>指令查看 key 的类型是哪个</td></tr><tr><td>del key</td><td>指令删除指定的 key</td></tr><tr><td>unlink key</td><td>指令根据 value 选择非阻塞删除（先将 keys 从 keysapce 元数据中删除，真正的删除会在后续异步操作）</td></tr><tr><td>expire key time</td><td>指令给指定的 key 设置过期时间（time 以秒为单位），当 key 过期时(生存时间为 0 )，它会被自动删除</td></tr><tr><td>ttl key</td><td>指令查看 key 还有多少秒过期，-1 表示永不过期，-2 表示已过期</td></tr><tr><td>select num</td><td>指令选择数据库，num 代表从 0-16，默认是 0</td></tr><tr><td>flushdb</td><td>清空当前库</td></tr><tr><td>flushall</td><td>清空所有库</td></tr></tbody></table><h3 id="字符串string-1" tabindex="-1">字符串String <a class="header-anchor" href="#字符串string-1" aria-label="Permalink to &quot;字符串String&quot;">​</a></h3><table tabindex="0"><thead><tr><th>指令</th><th>含义</th></tr></thead><tbody><tr><td>set &lt;key&gt; &lt;value&gt;</td><td>添加键值对，如果 key 已经存在则覆盖 value</td></tr><tr><td>get &lt;key&gt;</td><td>查看对应键值</td></tr><tr><td>append &lt;key&gt; &lt;value&gt;</td><td>追加到原值的末尾</td></tr><tr><td>strlen &lt;key&gt;</td><td>获得值的长度</td></tr><tr><td>setnx &lt;key&gt; &lt;value&gt;</td><td>只有 key 不存在时，才加入该 key 的值</td></tr><tr><td>incr &lt;key&gt;</td><td>将 key 中储存的数字值增 1，只能对数字值操作，如果为空，新增值为 1</td></tr><tr><td>decr &lt;key&gt;</td><td>将 key 中储存的数字值减 1，只能对数字值操作，如果为空，新增值为 -1</td></tr><tr><td>incrby / decrby &lt;步长&gt;</td><td>将 key 中储存的数字值增减。自定义步长</td></tr><tr><td>mset &lt;key1&gt; &lt;value&gt; &lt;key2&gt; &lt;value2&gt; ......</td><td>设置一个或者多个 key-value 键值对</td></tr><tr><td>mget &lt;key1&gt; &lt;key2&gt; ......</td><td>获取一个或者多个 key-value 键值对</td></tr><tr><td>msetnx &lt;key1&gt; &lt;value&gt; &lt;key2&gt; &lt;value2&gt; ......</td><td>同时设置一个或多个 key-value 对，当且仅当所有给定 key 都不存在</td></tr><tr><td>getrange &lt;key&gt; &lt;起始位置&gt; &lt;结束位置&gt;</td><td>获得值的范围，类似 java 中的 substring</td></tr><tr><td>getrange &lt;key&gt; &lt;起始位置&gt; &lt;value&gt;</td><td>用 value 覆写所储存的字符串值，从 &lt;起始位置&gt; 开始(索引从 0 开始)</td></tr><tr><td>setrange &lt;key&gt; &lt;位置&gt; &lt;newValue&gt;</td><td>设置指定区间范围内的值</td></tr><tr><td>setex &lt;key&gt; &lt;过期时间/秒&gt; &lt;value&gt;</td><td>设置键值的同时，设置过期时间，单位秒</td></tr><tr><td>psetex &lt;key&gt; &lt;过期时间/毫秒&gt; &lt;value&gt;</td><td>设置键值的同时，设置过期时间，单位毫秒</td></tr><tr><td>getset &lt;key&gt; &lt;value&gt;</td><td>以新换旧，设置了新值同时获得旧值</td></tr><tr><td>set user:1 value（json数据）</td><td>存储对象</td></tr></tbody></table><h3 id="列表list-1" tabindex="-1">列表List <a class="header-anchor" href="#列表list-1" aria-label="Permalink to &quot;列表List&quot;">​</a></h3><table tabindex="0"><thead><tr><th>指令</th><th>含义</th></tr></thead><tbody><tr><td>lpush/rpush &lt;key&gt; &lt;value1&gt; &lt;value2&gt; &lt;value3&gt; ...</td><td>从左边/右边插入一个或多个值，左右也就是首尾</td></tr><tr><td>lrange &lt;key&gt; &lt;start&gt; &lt;stop&gt;</td><td>按照索引下标获得元素(从左到右，先进后出)</td></tr><tr><td>lrange &lt;key&gt; 0 -1</td><td>如果 start 是 0，stop 是 -1，代表获取所有元素</td></tr><tr><td>lindex &lt;key&gt; &lt;index&gt;</td><td>按照索引下标获得元素(从左到右)（-1 代表最后一个，0 代表是第一个）</td></tr><tr><td>lpop/rpop &lt;key&gt;</td><td>从左边/右边吐出一个值。吐出后该值就不存在 key 中</td></tr><tr><td>rpoplpush &lt;key1&gt; &lt;key2&gt;</td><td>列表右边吐出一个值，插到列表左边，其中 key1 是 rpop 的 key，key2 是 lpush 的 key</td></tr><tr><td>llen &lt;key&gt;</td><td>获得列表长度</td></tr><tr><td>linsert &lt;key&gt; before/after &lt;value&gt; &lt;newValue&gt;</td><td>在元素某个值的前面/后面插入新值，如果 value 有多个，则插入最前面的那个</td></tr><tr><td>lrem &lt;key&gt; &lt;n&gt; &lt;value&gt;</td><td>从左边删除 n 个 value(从左到右)，如果有多个一样的 lement，则删除列表最前面的的</td></tr><tr><td>lset &lt;key&gt; &lt;index&gt; &lt;value&gt;</td><td>将列表 key 下标为 index 的值替换成 value</td></tr><tr><td>ltrim key</td><td>对一个列表进行修剪(trim)，只保留指定列表中区间内的元素，不在指定区间之内的元素都将被删除</td></tr></tbody></table><h3 id="集合set-1" tabindex="-1">集合Set <a class="header-anchor" href="#集合set-1" aria-label="Permalink to &quot;集合Set&quot;">​</a></h3><table tabindex="0"><thead><tr><th>指令</th><th>含义</th></tr></thead><tbody><tr><td>sadd &lt;key&gt; &lt;value1&gt; &lt;value2&gt; ...</td><td>将一个或多个 member 元素加入到集合 key 中，已经存在的 member 元素将被忽略</td></tr><tr><td>smembers &lt;key&gt;</td><td>取出该集合的所有值</td></tr><tr><td>sismember &lt;key&gt; &lt;value&gt;</td><td>判断集合是否为含有该值，有 1，没有 0</td></tr><tr><td>scard &lt;key&gt;</td><td>返回该集合的元素个数</td></tr><tr><td>srem &lt;key&gt; &lt;value1&gt; &lt;value2&gt; ...</td><td>删除集合中的某个元素</td></tr><tr><td>spop &lt;key&gt;</td><td>随机从该集合中吐出一个值，key 里就没有该值了</td></tr><tr><td>srandmember &lt;key&gt; &lt;n&gt;</td><td>随机从该集合中取出 n 个值。不会从集合中删除</td></tr><tr><td>smove &lt;key1&gt; &lt;key2&gt; &lt;value&gt;</td><td>把集合中一个值从一个集合移动到另一个集合，其中 key1 为要获取的集合，key2 为放入的集合</td></tr><tr><td>sinter &lt;key1&gt; &lt;key2&gt;</td><td>返回两个集合的交集元素</td></tr><tr><td>sunion &lt;key1&gt; &lt;key2&gt;</td><td>返回两个集合的并集元素</td></tr><tr><td>sdiff &lt;key1&gt; &lt;key2&gt;</td><td>返回两个集合的差集元素(key1 中的，不包含 key2 中的)</td></tr></tbody></table><h3 id="哈希hash-1" tabindex="-1">哈希Hash <a class="header-anchor" href="#哈希hash-1" aria-label="Permalink to &quot;哈希Hash&quot;">​</a></h3><table tabindex="0"><thead><tr><th>指令</th><th>含义</th></tr></thead><tbody><tr><td>hset &lt;key&gt; &lt;field1&gt; &lt;value&gt; &lt;field2&gt; &lt;value&gt; ...</td><td>给集合 key 的 filed 键赋值 value，批量也可以，4.0 之前是 hmset，现在 hset 也可以批量添加</td></tr><tr><td>hget &lt;key&gt; &lt;field&gt;</td><td>从 key 集合取出 value</td></tr><tr><td>hexists &lt;key&gt; &lt;field&gt;</td><td>查看哈希表 key 中，给定域 field 是否存在</td></tr><tr><td>hkeys &lt;key&gt;</td><td>列出该 hash 集合的所有 field</td></tr><tr><td>hvals &lt;key&gt;</td><td>列出该 hash 集合的所有 value</td></tr><tr><td>hincrby &lt;key&gt; &lt;field&gt; &lt;increment&gt;</td><td>为哈希表 key 中的域 field 的值加上增量</td></tr><tr><td>hsetnx &lt;key&gt; &lt;filed&gt; &lt;value&gt;</td><td>将哈希表 key 中的域 field 的值设置为 value ，当且仅当域 field 不存在</td></tr></tbody></table><h3 id="有序集合zset-1" tabindex="-1">有序集合Zset <a class="header-anchor" href="#有序集合zset-1" aria-label="Permalink to &quot;有序集合Zset&quot;">​</a></h3><table tabindex="0"><thead><tr><th>指令</th><th>含义</th></tr></thead><tbody><tr><td>zadd &lt;key&gt; &lt;score1&gt; &lt;value1&gt; &lt;score2&gt; &lt;value2&gt; ...</td><td>将一个或多个 member 元素及其 score 值加入到有序集 key 当中</td></tr><tr><td>zrange &lt;key&gt; &lt;start&gt; &lt;stop&gt; [withscores]</td><td>返回有序集 key 中，下标在 star t和 stop 之间的元素，带 WITHSCORES，可以让分数一起和值(从小到大)返回到结果集</td></tr><tr><td>zrevrange &lt;key&gt; &lt;start&gt; &lt;stop&gt; [withscores]</td><td>同上，改为从大到小排列</td></tr><tr><td>zrangebyscore &lt;key&gt; &lt;min&gt; &lt;max&gt; [withscores] [limit offset count]</td><td>返回有序集 key 中，所有 score 值介于 min 和 max 之间(包括等于 min 或 max )的成员。 有序集成员按 score 值递增(从小到大)次序排列</td></tr><tr><td>zrevrangebyscore &lt;key&gt; &lt;min&gt; &lt;max&gt; [withscores] [limit offset count]</td><td>同上，改为从大到小排列</td></tr><tr><td>zincrby &lt;key&gt; &lt;increment&gt; &lt;value&gt;</td><td>为元素的 score 加上增量</td></tr><tr><td>zrem &lt;key&gt; &lt;value&gt;</td><td>删除该集合下，指定值的元素</td></tr><tr><td>zcount &lt;key&gt; &lt;min&gt; &lt;max&gt;</td><td>统计该集合，分数区间内的元素个数</td></tr><tr><td>zrank &lt;key&gt; &lt;value&gt;</td><td>返回该值在集合中的排名，从 0 开始</td></tr><tr><td>zrevrank &lt;key&gt; &lt;value&gt;</td><td>返回有序集中成员的排名。其中有序集成员按分数值递减(从大到小)排序</td></tr></tbody></table></div></div></main><footer class="VPDocFooter" data-v-6dff760d data-v-9cfeacb9><!--[--><!--]--><!----><nav class="prev-next" aria-labelledby="doc-footer-aria-label" data-v-9cfeacb9><span class="visually-hidden" id="doc-footer-aria-label" data-v-9cfeacb9>Pager</span><div class="pager" data-v-9cfeacb9><a class="VPLink link pager-link prev" href="/course/learn_redis/02_install.html" data-v-9cfeacb9><!--[--><span class="desc" data-v-9cfeacb9>上一页</span><span class="title" data-v-9cfeacb9>02.安装</span><!--]--></a></div><div class="pager" data-v-9cfeacb9><a class="VPLink link pager-link next" href="/course/learn_redis/04_new-types.html" data-v-9cfeacb9><!--[--><span class="desc" data-v-9cfeacb9>下一页</span><span class="title" data-v-9cfeacb9>04.新增三大数据类型</span><!--]--></a></div></nav></footer><!--[--><!--]--></div></div></div><!--[--><!--]--></div></div><footer class="VPFooter has-sidebar" data-v-3efcb1ce data-v-b5994933><div class="container" data-v-b5994933><!----><p class="copyright" data-v-b5994933>版权所有 ©2019-2025 金信通科技有限公司&emsp; <a href="https://beian.miit.gov.cn/" target="_blank">川ICP备2024135086号</a> <br />联系人： 余总 15883753897</p></div></footer><!--[--><!--]--></div></div>
    <script>window.__VP_HASH_MAP__=JSON.parse("{\"aboutme.md\":\"xypFaIxq\",\"article_centos-nginx-cerbot-ssl.md\":\"Bghh5cvC\",\"article_delete_mode_moules.md\":\"bUyv7cPN\",\"article_docker.md\":\"DvkDT0CV\",\"article_frontend.md\":\"BsnggFV0\",\"article_globalusing.md\":\"ROADU40-\",\"article_httpclient.md\":\"DxV4kYhT\",\"article_index.md\":\"DNJHo8iy\",\"article_intellisense.md\":\"BOL85IBz\",\"article_log.md\":\"b_onST8k\",\"article_nuget-remove.md\":\"BDgYI837\",\"article_nvm.md\":\"CRJ5nqAx\",\"article_rabbitmq.md\":\"uhHxzeV3\",\"article_update.md\":\"CUkMuFnL\",\"article_usejwt.md\":\"CF4IH1Ki\",\"command_certbot.md\":\"B-Pk88Uz\",\"command_docker.md\":\"DDNBaSjo\",\"command_dotnet.md\":\"BdCtO8MR\",\"command_git.md\":\"BOWPn7sN\",\"command_index.md\":\"u8qbd1DR\",\"command_linux.md\":\"BtLiT2uN\",\"command_nginx.md\":\"BTnakFKj\",\"command_pm2.md\":\"C9B3mZis\",\"command_rabbitmq.md\":\"iaP7n_ti\",\"command_redis.md\":\"DcfeKyof\",\"command_sqlserver.md\":\"CZVo0bcJ\",\"command_vim.md\":\"B9V310r0\",\"course_index.md\":\"bYVGzLoA\",\"course_learn_design_00_index.md\":\"6p6tBX4O\",\"course_learn_design_01_singleton.md\":\"DVcOo2uk\",\"course_learn_design_02_factorymethod.md\":\"1WQQCefb\",\"course_learn_design_03_abstractfactory.md\":\"BRE3Ifmr\",\"course_learn_design_04_builder.md\":\"cB3g3EVY\",\"course_learn_design_05_prototype.md\":\"Ca6iCfyL\",\"course_learn_design_06_adapter.md\":\"BQ4e6tCV\",\"course_learn_design_07_bridge.md\":\"BFFsZrse\",\"course_learn_design_08_composite.md\":\"CPdO9rk5\",\"course_learn_design_09_decorator.md\":\"CQtrIwMa\",\"course_learn_design_10_facade.md\":\"BaEhklQy\",\"course_learn_design_11_flyweight.md\":\"BO1tJg-a\",\"course_learn_design_12_proxy.md\":\"8kYWZM_G\",\"course_learn_design_13_chainofresponsibility.md\":\"CCyLzUBI\",\"course_learn_design_14_command.md\":\"bP8NWTfM\",\"course_learn_design_15_interpreter.md\":\"7ZPN9qUJ\",\"course_learn_design_16_iterator.md\":\"CS3hMfA9\",\"course_learn_design_17_mediator.md\":\"mMXvVGL8\",\"course_learn_design_18_memento.md\":\"CS-3g5_S\",\"course_learn_design_19_observer.md\":\"Vny5TR4G\",\"course_learn_design_20_state.md\":\"BRY3OjuR\",\"course_learn_design_21_strategy.md\":\"CH5pwSvF\",\"course_learn_design_22_templatemethod.md\":\"CxS34ofw\",\"course_learn_design_23_visitor.md\":\"C8HlFoaw\",\"course_learn_docker_01_introduce.md\":\"DWAaJX2x\",\"course_learn_docker_designpattern.md\":\"7Uki99dd\",\"course_learn_docker_dockerlearn.md\":\"CoEZru73\",\"course_learn_es_01_introduce.md\":\"NL32r-o5\",\"course_learn_es_02_install.md\":\"7TOcoD9M\",\"course_learn_es_03_simple-curd.md\":\"DmYioOuc\",\"course_learn_es_04_hight-curd.md\":\"DzfUozle\",\"course_learn_es_05_net-curd.md\":\"D61OVK4W\",\"course_learn_es_07_cluster.md\":\"fBgTe3zs\",\"course_learn_es_08_high-concept.md\":\"CcaW6Jtx\",\"course_learn_es_09_distributed.md\":\"BrupOegx\",\"course_learn_es_10_shards-control.md\":\"Cp6nOKgV\",\"course_learn_es_11_shards-principle.md\":\"CtkpMIzb\",\"course_learn_es_12. elasticsearch - 多框架集成.md\":\"BbbP5UyG\",\"course_learn_es_12_analysis.md\":\"BE2TtHMm\",\"course_learn_es_13_handle.md\":\"ACn2i9rc\",\"course_learn_es_14_optimization.md\":\"DR3X4cmU\",\"course_learn_js_1_base copy 2.md\":\"Cmkh4X0b\",\"course_learn_js_1_base.md\":\"DpUjcv9f\",\"course_learn_js_1_base_bak.md\":\"CCpOz7RU\",\"course_learn_js_2_advaned copy.md\":\"DIhoveQY\",\"course_learn_js_2_advaned.md\":\"DEEQqEod\",\"course_learn_k8s_01_introduce.md\":\"CvqcD7L4\",\"course_learn_path_csharp.md\":\"B0a4x4DL\",\"course_learn_path_dotnetskill.md\":\"DOCzzvxY\",\"course_learn_path_index.md\":\"DUCkpDLe\",\"course_learn_path_upper_computer.md\":\"BnX-WG4P\",\"course_learn_path_webapi.md\":\"BJDC2d9A\",\"course_learn_path_wpf.md\":\"Ckal5wXk\",\"course_learn_rabbit_01_middleware.md\":\"IQpwVqCJ\",\"course_learn_rabbit_02_mq.md\":\"Dx5vrg5A\",\"course_learn_rabbit_03_introduce.md\":\"CUJgC_JM\",\"course_learn_rabbit_04_install.md\":\"Bn93LEpn\",\"course_learn_rabbit_05_basic.md\":\"BsNdT8Bc\",\"course_learn_rabbit_06_ackpub.md\":\"CD8SkqEM\",\"course_learn_rabbit_07_exchange.md\":\"BOSTRxOH\",\"course_learn_rabbit_08_dead.md\":\"CIiJoYh6\",\"course_learn_rabbit_09_delay.md\":\"DyaNJehA\",\"course_learn_rabbit_10_hightpub.md\":\"BSDvPvzD\",\"course_learn_rabbit_11_priority.md\":\"CZFgmjse\",\"course_learn_redis_01_introduce.md\":\"lAH7p6vP\",\"course_learn_redis_02_install.md\":\"CI_6DAkI\",\"course_learn_redis_03_data-types.md\":\"C-sFZOhK\",\"course_learn_redis_04_new-types.md\":\"fQC4EJmw\",\"course_learn_redis_05_configuration.md\":\"C0ulJkIb\",\"course_learn_redis_06_publish-subscribe.md\":\"Cix_w7XF\",\"course_learn_redis_07_net.md\":\"DdsxhOaj\",\"course_learn_redis_08_affair.md\":\"CwfAeURs\",\"course_learn_redis_09_persistence.md\":\"B-XRWvpt\",\"course_learn_redis_10_master-slave.md\":\"BxBSuhbo\",\"course_learn_redis_11_cluster.md\":\"D6b-fezs\",\"course_learn_redis_12_application.md\":\"CQnDC3oG\",\"course_learn_redis_13_distributed-lock.md\":\"DpBrwn3l\",\"course_learn_redis_30.redis - spring data redis.md\":\"Bg2x8C_J\",\"course_learn_sort_01_bubblesort.md\":\"rsY6eX3t\",\"course_learn_sort_02_selectionsort.md\":\"CkDQP4gt\",\"course_learn_sort_03_insertionsort.md\":\"RPmTmZH7\",\"course_learn_sort_04_shellsort.md\":\"ftYHFLZW\",\"course_learn_sort_05_mergesort.md\":\"BDq6cVaT\",\"course_learn_sort_06_quicksort.md\":\"DPrn3Psf\",\"course_learn_sort_07_heapsort.md\":\"J563DbfJ\",\"course_learn_sort_08_countingsort.md\":\"DgK1IXbW\",\"course_learn_sort_09_bucketsort.md\":\"C8dDAJlM\",\"course_learn_sort_10_radixsort.md\":\"nNI4lowy\",\"course_learn_ts_1_type.md\":\"2sLfBjJ4\",\"course_learn_ts_2_interface.md\":\"DSUjwK3L\",\"course_learn_ts_3_class.md\":\"jCtCdxrk\",\"course_learn_ts_4_function.md\":\"09RSIp5o\",\"course_learn_ts_5_generic.md\":\"zYF_-DAN\",\"course_learn_ts_6_other.md\":\"ByPck4O_\",\"guid_auth.md\":\"DIyQpEZ7\",\"guid_cache.md\":\"COuVZN91\",\"guid_conf-options_configuration.md\":\"C4-8NWsn\",\"guid_conf-options_options.md\":\"yK7iGQMD\",\"guid_cors.md\":\"CI_kZfxk\",\"guid_datavalidation.md\":\"Dr5Yvt2-\",\"guid_dependency-injection.md\":\"D6J4rsMZ\",\"guid_deployment_docker-deployment.md\":\"rDcD4Yil\",\"guid_deployment_linux-pm2-deployment.md\":\"R1YnLmLI\",\"guid_deployment_linux-systemd-deployment.md\":\"BE7NHHu5\",\"guid_deployment_supervisor-dotnet.md\":\"C_LtL8Gy\",\"guid_deployment_win-iis-deployment.md\":\"DGum87JZ\",\"guid_easy-use.md\":\"zFnP_iYc\",\"guid_exception-handling.md\":\"CQBXwUfU\",\"guid_exception.md\":\"tYrOQ2Lm\",\"guid_filter.md\":\"BjnpS61h\",\"guid_index.md\":\"Dy2usELz\",\"guid_intro.md\":\"CAqKDWHe\",\"guid_learn-path.md\":\"CDUdnsgD\",\"guid_log.md\":\"BwfveYLO\",\"guid_mapper.md\":\"DQAK2xp9\",\"guid_middleware_index.md\":\"BGdLK2W6\",\"guid_middleware_middleware.md\":\"zINdUd9X\",\"guid_openapi_standard.md\":\"COuI1l2E\",\"guid_openapi_swagger.md\":\"BT8axDut\",\"guid_orm_ef.md\":\"56WULw9z\",\"guid_orm_sqlsugar.md\":\"BiWFooEZ\",\"guid_other_sll.md\":\"BJhgQExd\",\"guid_quick-start.md\":\"8rJXoN6p\",\"guid_service_background-service.md\":\"VSigerwi\",\"guid_service_install.md\":\"DLpKst61\",\"guid_service_quartz-service.md\":\"huAo9HC6\",\"guid_service_topshelf.md\":\"BqgcvqjZ\",\"guid_signalr.md\":\"CDzrsNdZ\",\"guid_signalrdemo.md\":\"Boxzu3OO\",\"guid_swagger.md\":\"C19R_2TU\",\"index.md\":\"EwFlcPPh\",\"interview_basepaper1.md\":\"ClWwKGjT\",\"interview_basepaper2.md\":\"DV4tYHZC\",\"interview_basepaper3.md\":\"XCZL7YkI\",\"interview_basepaper4.md\":\"UsnichHU\",\"interview_groupfriends25.md\":\"Buk-IGOh\",\"interview_index.md\":\"Dqc3P2Zw\",\"interview_intermediate1.md\":\"WYMfe99V\",\"interview_intermediate2.md\":\"aqpAXC7n\",\"interview_intermediate3.md\":\"LlwwP0tI\",\"interview_randompaper1.md\":\"DJQkuS15\",\"interview_randompaper2.md\":\"CzqrwnDI\",\"interview_special_core.md\":\"CiesZkt5\",\"interview_special_es.md\":\"BkcE5Vtm\",\"interview_special_mysql.md\":\"Cg2SXuq3\",\"interview_special_net.md\":\"BlA12oCH\",\"interview_special_rabbitmq.md\":\"CjIz6UXL\",\"interview_special_redis.md\":\"DVnNlG8B\",\"interview_special_sqlserver.md\":\"CBDvv3GW\",\"interview_upper_computer_tcp.md\":\"C32hehD5\",\"interview_wpf_wpf_basepaper1.md\":\"5y8HZM3m\",\"interview_wpf_wpf_basepaper2_1.md\":\"DIzExcYa\",\"interview_wpf_wpf_basepaper2_2.md\":\"2Y_z_-B4\",\"interview_wpf_wpf_basepaper2_3.md\":\"DzuE4fM9\",\"interview_yuehai.md\":\"D4IW3Lww\",\"interview_zhiying.md\":\"B-bQ5sg6\",\"netopensource_assembly_blazor.md\":\"hLFID5sc\",\"netopensource_assembly_maui.md\":\"D1KqXitx\",\"netopensource_assembly_winfrom.md\":\"Bm0KNl4J\",\"netopensource_assembly_wpf.md\":\"aLkZZTJl\",\"netopensource_index.md\":\"Bmia1SBJ\",\"netopensource_library_ai.md\":\"B5rZsifC\",\"netopensource_library_crawler.md\":\"BfXHQDIc\",\"netopensource_library_dotnetzip.md\":\"CHfm7EMh\",\"netopensource_library_email.md\":\"FYDSyYhd\",\"netopensource_library_encryption.md\":\"26acF_kW\",\"netopensource_library_excel.md\":\"Btfgrz8M\",\"netopensource_library_ftp.md\":\"Czrg40UW\",\"netopensource_library_media.md\":\"CsOyE144\",\"netopensource_library_orm.md\":\"D5Mbnat3\",\"netopensource_library_other.md\":\"Ddg4xIgF\",\"netopensource_library_pdf.md\":\"Cl0D-L5y\",\"netopensource_library_qrcode.md\":\"D_U-JPbU\",\"netopensource_library_redis.md\":\"Cb6x1AgO\",\"netopensource_library_taskdispath.md\":\"y3bQhVy2\",\"netopensource_library_tool.md\":\"N42MhIrK\",\"netopensource_library_word.md\":\"BaemOm8q\",\"netopensource_project_blazor.md\":\"BZHCBj-r\",\"netopensource_project_blog.md\":\"DyLZWylT\",\"netopensource_project_cms.md\":\"UyCKdjN8\",\"netopensource_project_other.md\":\"C2GvlxeD\",\"netopensource_project_shop.md\":\"CDGQ4v0J\",\"netopensource_project_web-admin.md\":\"BvE_WXx9\",\"netopensource_project_wpf.md\":\"D3TxSMcS\"}");window.__VP_SITE_DATA__=JSON.parse("{\"lang\":\"en-US\",\"dir\":\"ltr\",\"title\":\"金信通智慧办公系统\",\"description\":\"档案与电子文档管理系统\",\"base\":\"/\",\"head\":[],\"router\":{\"prefetchLinks\":true},\"appearance\":true,\"themeConfig\":{\"nav\":[{\"text\":\"管理系统使用\",\"link\":\"guid/intro\"},{\"text\":\"档案柜配置\",\"link\":\"/command/dotnet\"},{\"text\":\"小程序使用\",\"link\":\"/netopensource/\"},{\"text\":\"链接\",\"items\":[{\"text\":\"MalusAdmin\",\"link\":\"https://malus.dotnetshare.com\"},{\"text\":\"Malus(开源地址)\",\"link\":\"https://gitee.com/Pridejoy/MalusAdmin\"}]}],\"sidebar\":{\"/guid/\":[{\"text\":\"指南\",\"items\":[{\"text\":\"开始\",\"link\":\"/guid/intro\"},{\"text\":\"数据校验\",\"link\":\"/guid/datavalidation\"},{\"text\":\"配置与选项\",\"base\":\"/guid/conf-options\",\"items\":[{\"text\":\"配置\",\"link\":\"/configuration\"},{\"text\":\"选项\",\"link\":\"/options\"}]},{\"text\":\"跨域处理\",\"link\":\"/guid/cors\"},{\"text\":\"开放接口\",\"base\":\"/guid/openapi\",\"items\":[{\"text\":\"Swagger\",\"link\":\"/swagger\"},{\"text\":\"规范化返回值\",\"link\":\"/standard\"}]},{\"text\":\"数据库操作\",\"base\":\"/guid/orm\",\"items\":[{\"text\":\"SqlSugar\",\"link\":\"/sqlsugar\"},{\"text\":\"EF\",\"link\":\"/ef\"}],\"link\":\"\"},{\"text\":\"对象关系映射\",\"link\":\"/guid/mapper\"},{\"text\":\"异常处理\",\"link\":\"/guid/exception-handling\"},{\"text\":\"依赖注入/控制反转\",\"link\":\"/guid/dependency-injection\"},{\"text\":\"缓存管理\",\"link\":\"/guid/cache\"},{\"text\":\"安全鉴权\",\"link\":\"/guid/auth\"},{\"text\":\"日志管理\",\"link\":\"/guid/log\"},{\"text\":\"中间件\",\"link\":\"/guid/middleware/\"},{\"text\":\"实时应用\",\"link\":\"/guid/signalr\"},{\"text\":\"进程服务\",\"base\":\"/guid/service\",\"items\":[{\"text\":\"后台服务\",\"link\":\"/background-service\"},{\"text\":\"安装部署\",\"link\":\"/install\"}]},{\"text\":\"托管部署\",\"base\":\"/guid/deployment\",\"items\":[{\"text\":\"IIS部署\",\"link\":\"/win-iis-deployment\"},{\"text\":\"Docker部署\",\"link\":\"/docker-deployment\"},{\"text\":\"使用PM2守护\",\"link\":\"/linux-pm2-deployment\"},{\"text\":\"使用Supervisor守护\",\"link\":\"/supervisor-dotnet\"},{\"text\":\"使用Systemd守护\",\"link\":\"/linux-systemd-deployment\"}]}]}],\"/command/\":[{\"text\":\"常用软件安装和命令\",\"items\":[{\"text\":\"DotNet\",\"link\":\"/command/dotnet\"},{\"text\":\"Sqlserver\",\"link\":\"/command/sqlserver\"},{\"text\":\"Nginx\",\"link\":\"/command/nginx\"},{\"text\":\"Pm2\",\"link\":\"/command/pm2\"},{\"text\":\"Redis\",\"link\":\"/command/redis\"},{\"text\":\"RabbitMQ\",\"link\":\"/command/rabbitmq\"},{\"text\":\"Docker\",\"link\":\"/command/docker\"},{\"text\":\"Git\",\"link\":\"/command/git\"},{\"text\":\"Certbot\",\"link\":\"/command/certbot\"},{\"text\":\"Linux\",\"link\":\"/command/linux\"},{\"text\":\"Vim\",\"link\":\"/command/vim\"}]}],\"/netopensource/\":[{\"text\":\"工具库\",\"collapsed\":true,\"base\":\"/netopensource/library\",\"items\":[{\"text\":\"ORM\",\"link\":\"/orm\"},{\"text\":\"Zip\",\"link\":\"/dotnetzip\"},{\"text\":\"Excel\",\"link\":\"/excel\"},{\"text\":\"Word\",\"link\":\"/word\"},{\"text\":\"Pdf\",\"link\":\"/pdf\"},{\"text\":\"条形码二维码\",\"link\":\"/qrcode\"},{\"text\":\"工具库\",\"link\":\"/tool\"},{\"text\":\"Ftp\",\"link\":\"/ftp\"},{\"text\":\"爬虫\",\"link\":\"/crawler\"},{\"text\":\"Redis\",\"link\":\"/redis\"},{\"text\":\"加密解密\",\"link\":\"/encryption\"},{\"text\":\"邮件\",\"link\":\"/email\"},{\"text\":\"其他库\",\"link\":\"/other\"}]},{\"text\":\"组件库\",\"base\":\"/netopensource/assembly\",\"collapsed\":true,\"items\":[{\"text\":\"Wpf\",\"link\":\"/wpf\"},{\"text\":\"MAUI\",\"link\":\"/maui\"},{\"text\":\"Blazor\",\"link\":\"/blazor\"},{\"text\":\"WinForm\",\"link\":\"/winfrom\"}]},{\"text\":\"开源项目\",\"collapsed\":true,\"base\":\"/netopensource/project\",\"items\":[{\"text\":\"Web-后台管理\",\"link\":\"/web-admin\"},{\"text\":\"Shop\",\"link\":\"/shop\"},{\"text\":\"博客\",\"link\":\"/blog\"},{\"text\":\"CMS\",\"link\":\"/cms\"},{\"text\":\"WPF\",\"link\":\"/wpf\"},{\"text\":\"Blazor\",\"link\":\"/blazor\"},{\"text\":\"其他\",\"link\":\"/other\"}]}],\"/interview/\":[{\"text\":\"面试题\",\"base\":\"/interview\",\"collapsed\":true,\"items\":[{\"text\":\"基础试题1\",\"link\":\"/basepaper1\"},{\"text\":\"基础试题2\",\"link\":\"/basepaper2\"},{\"text\":\"基础试题3\",\"link\":\"/basepaper3\"},{\"text\":\"基础试题4\",\"link\":\"/basepaper4\"},{\"text\":\"随机试题1\",\"link\":\"/randompaper1\"},{\"text\":\"随机试题2\",\"link\":\"/randompaper2\"},{\"text\":\"中高级开发工程师\",\"link\":\"/intermediate1\"},{\"text\":\"群友25k面试题\",\"link\":\"/groupfriends25\"},{\"text\":\"某公司.NET面试题1\",\"link\":\"/intermediate3\"},{\"text\":\"某公司.NET面试题2\",\"link\":\"/zhiying\"},{\"text\":\"某物流公司高级面试题\",\"link\":\"/yuehai\"}]},{\"text\":\"专项面试\",\"base\":\"/interview/special\",\"collapsed\":true,\"items\":[{\"text\":\"Redis高频\",\"link\":\"/redis\"},{\"text\":\"Sqlserver高频\",\"link\":\"/sqlserver\"},{\"text\":\"Mysql高频\",\"link\":\"/mysql\"},{\"text\":\"RabbitMQ高频\",\"link\":\"/rabbitmq\"},{\"text\":\"ASPNETCore笔试题\",\"link\":\"/core\"},{\"text\":\"NET笔试题基础篇\",\"link\":\"/net\"},{\"text\":\"ElasticSearch\",\"link\":\"/es\"}]},{\"text\":\"WPF面试\",\"collapsed\":true,\"items\":[{\"text\":\"基础面试\",\"link\":\"/interview/wpf/wpf_basepaper1\"},{\"text\":\"核心面试\",\"collapsed\":true,\"base\":\"interview/wpf\",\"link\":\"\",\"items\":[{\"text\":\"初级\",\"link\":\"/wpf_basepaper2_1\"},{\"text\":\"中级\",\"link\":\"/wpf_basepaper2_2\"},{\"text\":\"高级\",\"link\":\"/wpf_basepaper2_3\"}]}]},{\"text\":\"上位机面试\",\"collapsed\":true,\"items\":[{\"text\":\"基础面试\",\"link\":\"/interview/upper_computer/tcp\"}]}],\"/course/\":[{\"text\":\"学习路径\",\"base\":\"/course/learn_path\",\"items\":[{\"text\":\"学习资料\",\"link\":\"/index\"},{\"text\":\"AspNetCore开发指南\",\"link\":\"/webapi\"},{\"text\":\"Csharp代码大全\",\"link\":\"/csharp\"},{\"text\":\"DotNet知识技能大全\",\"link\":\"/dotnetskill\"}]},{\"text\":\"系列\",\"items\":[{\"text\":\"TS快速上手\",\"collapsed\":true,\"base\":\"/course/learn_ts\",\"items\":[{\"text\":\"1. 基础类型\",\"link\":\"/1_type\"},{\"text\":\"2. 接口\",\"link\":\"/2_interface\"},{\"text\":\"3. 类\",\"link\":\"/3_class\"},{\"text\":\"4. 函数\",\"link\":\"/4_function\"},{\"text\":\"5. 泛型\",\"link\":\"/5_generic\"},{\"text\":\"6. 其它\",\"link\":\"/6_other\"}]},{\"text\":\"十大排序\",\"collapsed\":true,\"base\":\"/course/learn_sort\",\"items\":[{\"text\":\"1.冒泡排序\",\"link\":\"/01_bubblesort\"},{\"text\":\"2.选择排序\",\"link\":\"/02_selectionsort\"},{\"text\":\"3.插入排序\",\"link\":\"/03_insertionsort\"},{\"text\":\"4.希尔排序\",\"link\":\"/04_shellsort\"},{\"text\":\"5.归并排序\",\"link\":\"/05_mergesort\"},{\"text\":\"6.快速排序\",\"link\":\"/06_quicksort\"},{\"text\":\"7.堆排序\",\"link\":\"/07_heapsort\"},{\"text\":\"8.计数排序\",\"link\":\"/08_countingsort\"},{\"text\":\"9.桶排序\",\"link\":\"/09_bucketsort\"},{\"text\":\"10.基数排序\",\"link\":\"/10_radixsort\"}]},{\"text\":\"设计模式\",\"collapsed\":true,\"base\":\"/course/learn_design\",\"link\":\"\",\"items\":[{\"text\":\"00.前言\",\"link\":\"/00_index\"},{\"text\":\"01.单例模式\",\"link\":\"/01_Singleton\"},{\"text\":\"02.工厂方法模式\",\"link\":\"/02_FactoryMethod\"},{\"text\":\"03.抽象工厂模式\",\"link\":\"/03_AbstractFactory\"},{\"text\":\"04.建造者模式\",\"link\":\"/04_Builder\"},{\"text\":\"05.原型模式\",\"link\":\"/05_Prototype\"},{\"text\":\"06.适配器模式\",\"link\":\"/06_Adapter\"},{\"text\":\"07.桥接模式\",\"link\":\"/07_Bridge\"},{\"text\":\"08.组合模式\",\"link\":\"/08_Composite\"},{\"text\":\"09.装饰器模式\",\"link\":\"/09_Decorator\"},{\"text\":\"10.外观模式\",\"link\":\"/10_Facade\"},{\"text\":\"11.享元模式\",\"link\":\"/11_Flyweight\"},{\"text\":\"12.代理模式\",\"link\":\"/12_Proxy\"},{\"text\":\"13.责任链模式\",\"link\":\"/13_ChainOfResponsibility\"},{\"text\":\"14.命令模式\",\"link\":\"/14_Command\"},{\"text\":\"15.解释器模式\",\"link\":\"/15_Interpreter\"},{\"text\":\"16.迭代器模式\",\"link\":\"/16_Iterator\"},{\"text\":\"17.中介者模式\",\"link\":\"/17_Mediator\"},{\"text\":\"18.备忘录模式\",\"link\":\"/18_Memento\"},{\"text\":\"19.观察者模式\",\"link\":\"/19_Observer\"},{\"text\":\"20.状态模式\",\"link\":\"/20_State\"},{\"text\":\"21.策略模式\",\"link\":\"/21_Strategy\"},{\"text\":\"22.模板方法模式\",\"link\":\"/22_TemplateMethod\"},{\"text\":\"23.访问者模式\",\"link\":\"/23_Visitor\"}]},{\"text\":\"ElasticSearch\",\"collapsed\":true,\"base\":\"/course/learn_es\",\"link\":\"\",\"items\":[{\"text\":\"01.基础概念\",\"link\":\"/01_introduce\"},{\"text\":\"02.安装\",\"link\":\"/02_install\"},{\"text\":\"03.基本操作\",\"link\":\"/03_simple-curd\"},{\"text\":\"04.高级操作\",\"link\":\"/04_hight-curd\"},{\"text\":\"05.NET操作\",\"link\":\"/05_net-curd.md\"},{\"text\":\"07.搭建集群\",\"link\":\"/07_cluster\"},{\"text\":\"08.进阶概念\",\"link\":\"/08_high-concept\"},{\"text\":\"09.分布式集群和路由计算\",\"link\":\"/09_distributed\"},{\"text\":\"10.分片控制流程\",\"link\":\"/10_shards-control\"},{\"text\":\"11.分片操作原理\",\"link\":\"/11_shards-principle\"},{\"text\":\"12.多种分析器\",\"link\":\"/12_analysis\"},{\"text\":\"13.冲突问题处理\",\"link\":\"/13_handle\"},{\"text\":\"14.进阶优化\",\"link\":\"/14_optimization\"}]},{\"text\":\"Redis\",\"collapsed\":true,\"base\":\"/course/learn_redis\",\"link\":\"\",\"items\":[{\"text\":\"01.基础概念\",\"link\":\"/01_introduce\"},{\"text\":\"02.安装\",\"link\":\"/02_install\"},{\"text\":\"03.五大数据类型及API\",\"link\":\"/03_data-types\"},{\"text\":\"04.新增三大数据类型\",\"link\":\"/04_new-types\"},{\"text\":\"05.配置文件\",\"link\":\"/05_configuration\"},{\"text\":\"06.发布和订阅\",\"link\":\"/06_publish-subscribe\"},{\"text\":\"07.NET整合\",\"link\":\"/07_net\"},{\"text\":\"08.事务与锁\",\"link\":\"/08_affair\"},{\"text\":\"09.两种持久化\",\"link\":\"/09_persistence\"},{\"text\":\"10.主从复制\",\"link\":\"/10_master-slave\"},{\"text\":\"11.集群搭建\",\"link\":\"/11_cluster\"},{\"text\":\"12.应用问题\",\"link\":\"/12_application\"},{\"text\":\"13.分布式锁\",\"link\":\"/13_distributed-lock\"}]},{\"text\":\"RabbitMQ\",\"collapsed\":true,\"base\":\"/course/learn_rabbit\",\"link\":\"\",\"items\":[{\"text\":\"01.中间件\",\"link\":\"/01_middleware\"},{\"text\":\"02.消息队列\",\"link\":\"/02_mq\"},{\"text\":\"03.介绍\",\"link\":\"/03_introduce\"},{\"text\":\"04.安装\",\"link\":\"/04_install\"},{\"text\":\"05.Net基础整合\",\"link\":\"/05_basic\"},{\"text\":\"06.应答与发布\",\"link\":\"/06_ackpub\"},{\"text\":\"07.交换机\",\"link\":\"/07_exchange\"},{\"text\":\"08.死信队列\",\"link\":\"/08_dead\"},{\"text\":\"09.延迟队列\",\"link\":\"/09_delay\"},{\"text\":\"10.高发部确认\",\"link\":\"/10_hightpub\"},{\"text\":\"11.优先级\",\"link\":\"/11_priority\"}]},{\"text\":\"Docker\",\"collapsed\":true,\"base\":\"/course/learn_docker\",\"link\":\"\",\"items\":[{\"text\":\"01.基础概念\",\"link\":\"/01_introduce\"}]},{\"text\":\"Kubernetes\",\"collapsed\":true,\"base\":\"/course/learn_k8s\",\"link\":\"\",\"items\":[{\"text\":\"01.基础概念\",\"link\":\"/01_introduce\"}]}]}]},\"socialLinks\":[{\"icon\":{\"svg\":\"<svg t=\\\"1703483542872\\\" class=\\\"icon\\\" viewBox=\\\"0 0 1309 1024\\\" version=\\\"1.1\\\" xmlns=\\\"http://www.w3.org/2000/svg\\\" p-id=\\\"6274\\\" width=\\\"200\\\" height=\\\"200\\\"><path d=\\\"M1147.26896 912.681417l34.90165 111.318583-127.165111-66.823891a604.787313 604.787313 0 0 1-139.082747 22.263717c-220.607239 0-394.296969-144.615936-394.296969-322.758409s173.526026-322.889372 394.296969-322.889372C1124.219465 333.661082 1309.630388 478.669907 1309.630388 656.550454c0 100.284947-69.344929 189.143369-162.361428 256.130963zM788.070086 511.869037a49.11114 49.11114 0 0 0-46.360916 44.494692 48.783732 48.783732 0 0 0 46.360916 44.494693 52.090549 52.090549 0 0 0 57.983885-44.494693 52.385216 52.385216 0 0 0-57.983885-44.494692z m254.985036 0a48.881954 48.881954 0 0 0-46.09899 44.494692 48.620028 48.620028 0 0 0 46.09899 44.494693 52.385216 52.385216 0 0 0 57.983886-44.494693 52.58166 52.58166 0 0 0-57.951145-44.494692z m-550.568615 150.018161a318.567592 318.567592 0 0 0 14.307712 93.212943c-14.307712 1.080445-28.746387 1.768001-43.283284 1.768001a827.293516 827.293516 0 0 1-162.394168-22.296458l-162.001279 77.955749 46.328175-133.811485C69.410411 600.858422 0 500.507993 0 378.38496 0 166.683208 208.689602 0 463.510935 0c227.908428 0 427.594322 133.18941 467.701752 312.379588a427.463358 427.463358 0 0 0-44.625655-2.619261c-220.24709 0-394.100524 157.74498-394.100525 352.126871zM312.90344 189.143369a64.270111 64.270111 0 0 0-69.803299 55.659291 64.532037 64.532037 0 0 0 69.803299 55.659292 53.694846 53.694846 0 0 0 57.852923-55.659292 53.465661 53.465661 0 0 0-57.852923-55.659291z m324.428188 0a64.040926 64.040926 0 0 0-69.574114 55.659291 64.302852 64.302852 0 0 0 69.574114 55.659292 53.694846 53.694846 0 0 0 57.951145-55.659292 53.465661 53.465661 0 0 0-57.951145-55.659291z\\\" p-id=\\\"6275\\\"></path></svg>\"},\"link\":\"/aboutme.html\",\"ariaLabel\":\"wechat\"}],\"footer\":{\"copyright\":\"版权所有 ©2019-2025 金信通科技有限公司&emsp; <a href=\\\"https://beian.miit.gov.cn/\\\" target=\\\"_blank\\\">川ICP备2024135086号</a> <br />联系人： 余总 15883753897\"},\"search\":{\"provider\":\"local\"},\"docFooter\":{\"prev\":\"上一页\",\"next\":\"下一页\"},\"outline\":{\"label\":\"页面导航\",\"level\":[2,4]},\"lastUpdated\":{\"text\":\"最后更新于\",\"formatOptions\":{\"dateStyle\":\"short\",\"timeStyle\":\"medium\"}},\"langMenuLabel\":\"多语言\",\"returnToTopLabel\":\"回到顶部\",\"sidebarMenuLabel\":\"菜单\",\"darkModeSwitchLabel\":\"主题\",\"lightModeSwitchTitle\":\"切换到浅色模式\",\"darkModeSwitchTitle\":\"切换到深色模式\"},\"locales\":{},\"scrollOffset\":134,\"cleanUrls\":false}");</script>
    
  </body>
</html>